class Person
{
private String name;
private String id;
private double salary;
Person(String name,String id,double salary)
{
this.name=name;
this.id=id;
this.salary=salary;
}
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 setSalary(double salary)
{
this.salary=salary;
}
public double getSalary()
{
return salary;
}
public void get()
{
System.out.println("姓名:"+name+"工号:"+id+"薪水:"+salary);
}
}
class Woker extends Person
{
Woker(String name,String id,double salary)
{
super(name,id,salary);
}
public void woker()
{
System.out.println("工人工作");
}
}
class Maneager extends Person
{
private double prize;
Maneager(String name,String id,double salary,double prize)
{
super(name,id,salary);
this.prize=prize;
}
public void prize()
{
System.out.println("奖金:"+prize);
}
public void woker()
{
System.out.println("经理工作");
}
}
class PersonTest
{
public static void main(String[] args)
{
Woker w=new Woker("zhangsan","00012",5000);
w.get();
w.woker();
Maneager m=new Maneager("lisi","000001",20000,100000);
m.get();
m.prize();
m.woker();
}
} |
|