老师在类Employee里面写了一个抽象方法,但是累Employee没有被abstract修饰,抽象方法不是一定要写在抽象类里面吗?是不是老师忘记写了,还是我理解错了?下面是代码:
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
{
private double bonus;
Manager(String name,String id,double pay,double bonus)
{
super(name,id,pay);
this.bonus = bonus;
}
public void wor()
{
System.out.println("manager work!");
}
}
class Pro extends Employee
{
Pro(String name,String id,double pay)
{
super(name,id,pay);
}
public void work()
{
System.out.println("pro work");
}
}
|