類之間的關係(Staff manager和Admin類繼承employee類)
阿新 • • 發佈:2019-01-25
分析:
在已經實現各個角色的共同功能,可以通過繼承的方式重用相關程式碼
參考解決方案:
public class Staff extends Employee{
public Staff(){
super();
}
public Staff(int userId,String empNo,String userName,String password,int departId,int roleId,double salary){
super(userId,empNo,userName,password,departId,roleId,salary);
}
}
public class Manager extends Employee {
public Manager(){
super();
}
public Manager(int userId,String empNo,String userName,String password,int departId,int roleId,double salary){
super(userId,empNo,userName,password,departId,roleId,salary);
}
}
public class Admin extends Employee{
public Admin(){
super();
}
public Admin(int userId,String empNo,String userName,String password,int departId,int roleId,double salary){
super(userId,empNo,userName,password,departId,roleId,salary);
}
}