//员工包含三个属性:姓名,id,工资,经理也是员工,除了包含员工的属性外,还有一个奖金属性,请使用继思想设计出员工和经理类,要求类中提供必要的方法
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
{
pro(String name,String id,double pay)
{
super(name,id,pay);
}
public void work()
{
System.out.println("pro work");
}
}
class workerDemo
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
编译时候提示Employee不是抽象的,不能覆盖抽象work()方法,是哪里出问题啦? |
|