根据需求,完成如下代码(按照标准格式写),并在测试类中进行测试。
需求一:
项目经理类
属性:姓名 工号 工资 奖金
行为:工作work
程序员类
属性:姓名 工号 工资
行为:工作work
class Text1 {
public static void main(String[] args) {
Jing j = new Jing("张三","007",18000,20000);
j.show();
Yuan y = new Yuan("李四","008",20000);
y.show();
}
}
class Employee{
private String name;
private String id;
private int salary;
public Employee(){}
public Employee(String name,String id,int 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(int salary){
this.salary = salary;
}
public int getSalary(){
return salary;
}
public void work(){
System.out.println("工作");
}
}
class Jing extends Employee{
private int money;
public Jing(){}
public Jing(String name,String id,int salary,int money){
super(name,id,salary);
this.money = money;
}
public void show(){
System.out.println(getName()+" "+getId()+" "+getSalary()+" "+money);
}
}
class Yuan extends Employee{
public Yuan(){}
public Yuan(String name,String id,int salary){
super(name,id,salary);
}
public void show(){
System.out.println(getName()+" "+getId()+" "+getSalary());
}
}
|
|