abstract class Staff
{
private String name;
private int number;
private int wage;
public Staff(){}
public Staff(String name,int number,int wage)
{
this.name=name;
this.number=number;
this.wage=wage;
}
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return name;
}
public void setNumber(int number)
{
this.number=number;
}
public int getNumber()
{
return number;
}
public void setWage(int wage)
{
this.wage=wage;
}
public int getWage()
{
return wage;
}
public abstract void work();
}
//程序员 简单的继承
class Programmer extends Staff
{
//public Programmer(){}
public void work()
{
System.out.println("程序员的工作就是写代码");
}
}
//项目经理 简单继承+奖金
interface Prize
{
public abstract void money();
}
class Manager extends Staff implements Prize
{
//public Manager(){}
public void work()
{
System.out.println("项目经理的工作就是带项目");
}
public void money()
{
System.out.println("经理有奖金");
}
}
class WokerTest
{
public static void main (String[] args)
{
Programmer p=new Programmer();
p.setName("小明");
p.setNumber(11);
p.setWage(4322);
System.out.println(p.getName()+"***"+p.getNumber()+"*****"+p.getWage());
p.work();
Manager m=new Manager();
m.setName("明哥");
m.setNumber(21);
m.setWage(8322);
System.out.println(p.getName()+"***"+p.getNumber()+"*****"+p.getWage());
m.work();
m.money();
}
} |
|