public class Homework03 {
public static void main(String[] args) {
Employee e1 = new Programmer("张三",2019001,4500,1000);
e1.show();
e1.work();
e1 = new Tester("李四",2019002,4000);
e1.show();
e1.work();
e1 = new Manager("王五",2019003,6000,2000);
e1.show();
e1.work();
}
}
//员工类
abstract class Employee{
String name;
int id;
double salary;
//抽象方法工作
public abstract void work();
//抽象方法show
public abstract void show();
}
//程序员类
class Programmer extends Employee{
int bonous;
public Programmer(String name,int id,double Salary,int bonous) {
super();
this.name = name;
this.id = id;
this.salary = salary;
this.bonous = bonous;
}
@Override
public void work() {
System.out.println("软件开发");
}
@Override
public void show() {
System.out.println("姓名:"+name+",工号:"+id+",工资:"+salary+",奖金:"+bonous);
}
}
//测试工程师类
class Tester extends Employee{
public Tester(String name,int id,double Salary) {
super();
this.name = name;
this.id = id;
this.salary = salary;
}
@Override
public void work() {
System.out.println("软件测试");
}
@Override
public void show() {
System.out.println("姓名:"+name+",工号:"+id+",工资:"+salary);
}
}
//项目经理类
class Manager extends Employee{
int bonous;
public Manager(String name,int id,double Salary,int bonous) {
super();
this.name = name;
this.id = id;
this.salary = salary;
this.bonous = bonous;
}
@Override
public void work() {
System.out.println("控制进度");
}
@Override
public void show() {
System.out.println("姓名:"+name+",工号:"+id+",工资:"+salary+",奖金:"+bonous);
}
}