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 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;
}
public abstract void work();
public void show()
{
System.out.println("name:"+name+",id:"+id+",pay:"+pay);
}
}
class YuanGong extends Employee
{
YuanGong(String name,String id,double pay)
{
super(name,id,pay);
}
public void work()
{
System.out.println("YuanGong work");
}
}
class JingLi extends Employee
{
private double bonus;
JingLi(String name,String id,double pay,double bonus)
{
super(name,id,pay);
this.bonus = bonus;
}
public void work()
{
System.out.println("JingLi work");
}
}
class SingleTest
{
public static void main(String[] args)
{
YuanGong yg=new YuanGong("zhangsan","01",2000);
yg.work();
yg.show();
yg.setName("lisi");
yg.show();
}
}
//通过上程序可以获取员工和经理的姓名,工号,和工资。但经理有奖金,在输出经理的信息时,怎么姓名,工号,工资,奖金一起输出,
|