public class StaffDemo {
public static void main(String[] args) {
Programmer s=new Programmer();
s.setNameString("程序员小明");
s.setNumber(534123);
s.setSalary(31212312123123123213123123d);
System.out.println("名字:"+s.getNameString()+",工号"+s.getNumber()+",薪水"+s.getSalary());
s.work();
Manager s1 = new Manager();
s1.setNameString("项目经理小红");
s1.setNumber(86779);
s1.setSalary(1d);
System.out.println("名字:"+s1.getNameString()+",工号"+s1.getNumber()+",薪水"+s1.getSalary());
s1.work();
s1.moreMoney();
}
}
abstract class Staff{
private String nameString;
private int number;
private double salary;
public String getNameString() {
return nameString;
}
public void setNameString(String nameString) {
this.nameString = nameString;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
number = number;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public abstract void work();
}
interface Money{
public abstract void moreMoney();
}
class Programmer extends Staff{
public void work(){
System.out.println("程序员最苦逼的工作");
}
}
class Manager extends Staff implements Money{
public void moreMoney(){
System.out.println("项目经理提成15%");
}
public void work(){
System.out.println("项目经理从苦逼的工作上升级过来的");
}
} |
|