請參閱下面的代碼。我看不到我錯在哪裏。我也很困惑!非常感謝您的幫助!無法獲得裝飾模式工作
package code;
public class Client {
public static void main(String[] args){
proxyPlane plane = new proxyPlane(new Pilot(18));
plane.flyPlane();
plane = new proxyPlane(new Pilot(25));
plane.flyPlane();
DecoratedPilot decPilot = new Pilot(35);
System.out.println("Experienced Pilot of age " + Pilot.Age() + " " + decPilot.getDecotation());
}
}
package code;
public interface DecoratedPilot {
public String getDecotation();
}
package code;
public class Decoration extends PilotDecorator {
public Decoration(Pilot pilot) {
super(pilot);
// TODO Auto-generated constructor stub
}
@Override
public String getDecotation() {
return "Pilot has earned his Commercial Wings";
}
}
package code;
public abstract class PilotDecorator implements DecoratedPilot {
public PilotDecorator(Pilot pilot)
{
apilot = pilot;
}
}
package code;
public class Pilot implements DecoratedPilot {
private static int age;
public static int Age() {
return age;
}
public Pilot(int age){
Pilot.age = age;
}
public String getDecotation() {
// TODO Auto-generated method stub
return null;
}
}
你的問題是什麼? – romaintaz
你會得到什麼輸出,以及你期望輸出什麼? – Polygnome
請正確地縮進並格式化代碼,其確實很難像這樣讀取。 – Brady