//http://www.moviemalls.com/M/memento.htm /** * This tests Memento and handles the state push and pop itself * So consider this the application (a separate one could have been constructed). *
Memento Design Pattern example for COM1204 Summer 2003. * * @author Bob Futrelle * @version 0.1, 4 July 2003 * */ public class MementoTest { public static void main(String[] args) { StateStore states = new StateStore(); Engine eng = new Engine(); eng.postResult(); eng.add(7); // 7 states.addMemo(eng); // 7 eng.times(5); // 35 eng.add(4); states.addMemo(eng); // 39 eng.add(1); // 40 states.redoMemo(eng); // 39 states.redoMemo(eng); // 7 states.redoMemo(eng); // no more states.redoMemo(eng); // no more } // main() } // class Engine