class Employee//这是一个视频中的例子,按理说抽象方法一定定义在抽象类中,为什么这个类中有个抽象方法而这个类不是抽象的呢?
{
private string name;
private string id;
private double pay;
Employee(string name,string id,double pay)
{
this.name=name;
this.id=id;
this.pay=pay;
}
public abstract void work();
}
class Manager extends Employee
{
private int bonus;
Manager(string name,string id,double pay,int bonus)
{
super(name,id,pay);
this.bonus=bonus;
}
public void work()
{
System.out.println("manager work");
}
}
class Pro extends Employee
{
class Pro(string name,string id,double pay)
{
super(name,id,pay);
}
public void work()
{
System.out.println("Pro work");
}
}
public class AbstactDemo
{
public static void main(String[] args)
{
Manager man=new Manager(zhansan,01,100.00,400 );
Pro p=new Pro(lisi,05,200.00);
man.work();
p.work();
}
} |
|