黑马程序员技术交流社区
标题:
项目经理,程序员类练习.
[打印本页]
作者:
chenshaohua
时间:
2016-5-28 23:37
标题:
项目经理,程序员类练习.
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);
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2