类中有抽象的方法,此类即为抽象类,抽象方法必须在子类中被重写
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication10
{
    
class Program
    
{
        
static void Main(string[] args)
        
{
            HR a 
= new HR();
            Sales b 
= new Sales();
            manger c 
= new manger();
            
string d = Console.ReadLine();
            
if (d == "HR")
            
{
                a.pay();
                Console.ReadKey();
            }

            
if (d == "Sales")
            
{
                b.pay();
                Console.ReadKey();
            }

            
if (d == "manger")
            
{
                c.pay();
                Console.ReadKey();
            }

        }

    }

    
    
public abstract class user
    
{
        
        
public abstract void pay();
       
    }

    
public class HR:user
    
{
        
public override void pay()
        
{
            Console.WriteLine(
"4000");
        }

    }

    
public class Sales : user
    
{
        
public override void pay()
        
{
            Console.WriteLine(
"2000") ;
        }

    }

    
public class manger : user
    
{
        
public override void pay()
        
{
            Console.WriteLine(
"10000");
        }

    }

}

posted on 2007-08-18 10:23  ATP.NET  阅读(209)  评论(0编辑  收藏  举报