//操作控制器接口 public interface OperationController { void controlOperation(); }
//生产三种操作控制器接口 public class SymbianOperationController implements OperationController { @Override public void controlOperation() { System.out.println("使用Symbian系统操作控制"); } }
public class AndroidOperationController implements OperationController { @Override public void controlOperation() { System.out.println("使用Android系统操作控制"); } }
public class WindowsOperationController implements OperationController { @Override public void controlOperation() { System.out.println("使用Windows Mobile系统操作控制"); } }
//分别生成三种界面控制器 public class SymbianInterfaceController implements InterfaceController { @Override public void controlInterface() { System.out.println("使用Symbian系统游戏界面控制"); } }
public class AndroidInterfaceController implements InterfaceController { @Override public void controlInterface() { System.out.println("使用Android系统游戏界面控制"); } }
public class WindowsInterfaceController implements InterfaceController { @Override public void controlInterface() { System.out.println("使用Windows Mobile系统游戏界面控制"); } }
//生产三种不同系统的抽象工厂 public class SymbianSysFactory implements SysFactory { @Override public InterfaceController createInterface() { return new SymbianInterfaceController(); }
@Override public OperationController createOperation() { return new SymbianOperationController(); } }
public class AndroidSysFactory implements SysFactory { @Override public InterfaceController createInterface() { return new AndroidInterfaceController(); }
@Override public OperationController createOperation() { return new AndroidOperationController(); } }
public class WindowsSysFactory implements SysFactory { @Override public InterfaceController createInterface() { return new WindowsInterfaceController(); }
@Override public OperationController createOperation() { return new WindowsOperationController(); } }