@@ -0,0 +1,1239 @@
+// --------------------- %E7%8A%B6%E6%80%81%E6%8E%A5%E5%8F%A3%0A%0Apublic interface State %7B%0A    void handle1();%0A    void handle2();%0A%7D%0A%0A// --------------------- %E5%85%B7%E4%BD%93%E7%8A%B6%E6%80%81%0A%0Apublic class ConcreteState1 implements State %7B%0A    public void handle1() %7B%0A        System.out.println(%22ConcreteState1 handle1...%22);%0A    %7D%0A%0A    public void handle2() %7B%0A        System.out.println(%22ConcreteState1 handle2...%22);%0A    %7D%0A%7D%0A%0Apublic class ConcreteState2 implements State %7B%0A        public void handle1() %7B%0A            System.out.println(%22ConcreteState2 handle1...%22);%0A        %7D%0A%0A        public void handle2() %7B%0A            System.out.println(%22ConcreteState2 handle2...%22);%0A        %7D%0A%7D%0A%0A// --------------------- %E7%8E%AF%E5%A2%83%E7%B1%BB%0A%0Apublic class Context %7B%0A    private State state;%0A%0A    public Context(State state) %7B%0A        this.state = state;%0A    %7D%0A%0A    public void setState(State state) %7B%0A        this.state = state;%0A    %7D%0A%0A    public void handle1() %7B%0A        state.handle1();%0A    %7D%0A%0A    public void handle2() %7B%0A        state.handle2();%0A    %7D%0A%7D%0A%0A// --------------------- test code%0A%0Apublic static void main(String%5B%5D args) %7B%0A    Context context = new Context(new ConcreteState1());%0A%0A    context.handle1();%0A    context.handle2();%0A%0A    context.setState(new ConcreteState2());%0A%0A    context.handle1();%0A    context.handle2();%0A%7D

add state pattern