public abstract class Manger {
protected Manger superior; //上级
protected String postion; //职位
public Manger(String position) { //构造方法设置
this.postion=position; //你的职位
}
public void setsuperior(Manger superior) {
this.superior=superior;
} //设置上级
public abstract void dealrequdst(String request) ;
}
public class Leverone extends Manger {
public Leverone(String string) { //构造方法设置职位
super(string);
}
public void dealrequdst(String request) {
if (request.equals("加薪100")) {
System.out.println(postion+": "+"请求通过");
}
else if (superior!=null) {
superior.dealrequdst(request);
}
}
}
public class Levertwo extends Manger {
public Levertwo(String string) {
super(string);
}
public void dealrequdst(String request) {
if (request.equals("加薪200")) {
System.out.println(postion+": "+"请求通过");
}
else if (superior!=null) {
superior.dealrequdst(request);
}
}
}
public class Leverthree extends Manger {
public Leverthree(String string) {
super(string);
}
public void dealrequdst(String request) {
if (request.equals("加薪300")) {
System.out.println(postion+": "+"请求通过");
}
else {
System.out.println(postion+": "+"不可以");
}
}
}
public class Client {
public static void main(String[] args) {
Leverone leverone=new Leverone("主管");
Levertwo levertwo=new Levertwo("经理");
Leverthree leverthree=new Leverthree("总经理");
leverone.setsuperior(levertwo);
levertwo.setsuperior(leverthree);
leverone.dealrequdst("加薪200");
}
}