class Demo3 {
public static void main(String[] args) {
Manager m = new Manager("张三","123456",9000,2000);
m.behavior();
System.out.println(m.getName() +"的工号是:" + m.getJobNum() +
"工资是:" + m.getSalary() + "奖金是:" + m.getBonus());
Staff s = new Staff("李四","123654",5000);
s.behavior();
System.out.println(s.getName() +"的工号是:" + s.getJobNum() +
"工资是:" + s.getSalary());
}
}
class Person {
private String name;
private String jobNum;
private int salary;
public Person() {
}
public Person(String name, String jobNum, int salary) {
this.name = name;
this.jobNum = jobNum;
this.salary = salary;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getJobNum() {
return jobNum;
}
public void setJobNum(String jobNum) {
this.jobNum = jobNum;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public void behavior() {
System.out.println("工作");
}
}
class Manager extends Person {
private int bonus;
public Manager() {
}
public Manager(String name, String jobNum, int salary,int bonus) {
super(name, jobNum, salary);
this.bonus = bonus;
}
public int getBonus() {
return bonus;
}
public void setBonus(int bonus) {
this.bonus = bonus;
}
}
class Staff extends Person {
public Staff() {
}
public Staff(String name, String jobNum, int salary) {
super(name, jobNum, salary);
}
}
|
|