//员工类:name id pay
//经理类:继承了员工的属性,并有bonus.
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;
}
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 extendsDemo02
{
//Pro p= new Pro("zhangsan","2083",10000);
//p.work(); //ExtendsDemo02.java:43: 错误: 需要<标识符>
Manager m=new Manager("lisi","jl01",10000,2000);
m.work();
} |