using
System;
class Employee
... {
protected string _name;//只被本类或派生类访问
public Employee()//默认构造函数
...{ }
public Employee(string name)
...{
_name = name;
}
public virtual void strartWork()//虚方法
...{
Console.Write(_name + "开始工作:");
}
}
class Manager : Employee
... {
public Manager(string name): base(name)//指写构造函数
...{ }
public override void strartWork()//重写基类虚方法
...{
base.strartWork();
Console.WriteLine("给员工下达任务");
}
}
class xs : Employee
... {
public xs(string name):base(name)//指写构造函数
...{ }
public override void strartWork()
...{
base.strartWork();
Console.WriteLine("销售产品");
}
}
class ms : Employee
... {
public ms(string name) : base(name)//指写构造函数
...{ }
public override void strartWork()
...{
base.strartWork();
Console.WriteLine("经理助理");
}
}
class kj : Employee
... {
public kj(string name) : base(name)//指写构造函数
...{ }
public override void strartWork()
...{
base.strartWork();
Console.WriteLine("财务核算");
}
}
class Test
... {
static void Main()
...{
Employee [] emp =new Employee[4];
emp[0]=new Manager("张三");
emp[1]=new xs("李四");
emp[2]=new ms("王五");
emp[3]=new kj("赵六");
Console.WriteLine("上午8点开始工作:");
foreach(Employee e in emp)
...{
e.strartWork();
}
}
}
class Employee
... {
protected string _name;//只被本类或派生类访问
public Employee()//默认构造函数
...{ }
public Employee(string name)
...{
_name = name;
}
public virtual void strartWork()//虚方法
...{
Console.Write(_name + "开始工作:");
}
}
class Manager : Employee
... {
public Manager(string name): base(name)//指写构造函数
...{ }
public override void strartWork()//重写基类虚方法
...{
base.strartWork();
Console.WriteLine("给员工下达任务");
}
}
class xs : Employee
... {
public xs(string name):base(name)//指写构造函数
...{ }
public override void strartWork()
...{
base.strartWork();
Console.WriteLine("销售产品");
}
}
class ms : Employee
... {
public ms(string name) : base(name)//指写构造函数
...{ }
public override void strartWork()
...{
base.strartWork();
Console.WriteLine("经理助理");
}
}
class kj : Employee
... {
public kj(string name) : base(name)//指写构造函数
...{ }
public override void strartWork()
...{
base.strartWork();
Console.WriteLine("财务核算");
}
}
class Test
... {
static void Main()
...{
Employee [] emp =new Employee[4];
emp[0]=new Manager("张三");
emp[1]=new xs("李四");
emp[2]=new ms("王五");
emp[3]=new kj("赵六");
Console.WriteLine("上午8点开始工作:");
foreach(Employee e in emp)
...{
e.strartWork();
}
}
}