这个向上提取一个抽象类员工Employee类,
[AppleScript] 纯文本查看 复制代码 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 woke();
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return name;
}
public void setId(String id)
{
this.id=id;
}
public String getId()
{
return id;
}
public void setPay(double pay)
{
this.pay=pay;
}
public double getPay()
{
return pay;
}
}
class Programmer extends Employee
{
Programmer(String name,String id,double pay)
{
super(name,id,pay);
}
public void woke()
{
System.out.println("code");
}
}
class ProjectManager extends Employee
{
private double bonus;
ProjectManager(String name,String id,double pay,double bonus)
{
super(name,id,pay);
this.bonus=bonus;
}
public void woke()
{
System.out.println("manage");
}
public double getBonus()
{
return bonus;
}
public void setBonus(double bonus)
{
this.bonus=bonus;
}
}
class Demo2
{
public static void main(String[] args)
{
ProjectManager pm=new ProjectManager("张三","a123",6000,3000);
pm.woke();
System.out.println("姓名:"+pm.getName()+",工号:"+pm.getId()+",薪水:"+pm.getPay()+",奖金:"+pm.getBonus());
Programmer p=new Programmer("李四","b111",3000);
p.woke();
System.out.println("姓名:"+p.getName()+",工号:"+p.getId()+",薪水:"+p.getPay());
}
} |