@@ -0,0 +1,880 @@
+class Originator %7B%0A    private String state;%0A    // The class could also contain additional data that is not part of the%0A    // state saved in the memento.%0A %0A    public void set(String state) %7B%0A        System.out.println(%22Originator: Setting state to %22 + state);%0A        this.state = state;%0A    %7D%0A %0A    public Memento saveToMemento() %7B%0A        System.out.println(%22Originator: Saving to Memento.%22);%0A        return new Memento(state);%0A    %7D%0A %0A    public void restoreFromMemento(Memento memento) %7B%0A        state = memento.getSavedState();%0A        System.out.println(%22Originator: State after restoring from Memento: %22 + state);%0A    %7D%0A %0A    public static class Memento %7B%0A        private final String state;%0A %0A        private Memento(String stateToSave) %7B%0A            state = stateToSave;%0A        %7D%0A %0A        private String getSavedState() %7B%0A            return state;%0A        %7D%0A    %7D%0A%7D%0A

Create Originator.java