added memento sample

This commit is contained in:
Ilkka Seppala
2014-08-22 21:31:08 +03:00
parent 128aff2802
commit 13257b8b33
7 changed files with 185 additions and 0 deletions
@@ -0,0 +1,30 @@
package com.iluwatar;
import java.util.Stack;
public class App
{
public static void main( String[] args )
{
Stack<StarMemento> states = new Stack<>();
Star star = new Star(StarType.SUN, 10000000, 500000);
System.out.println(star);
states.add(star.getMemento());
star.timePasses();
System.out.println(star);
states.add(star.getMemento());
star.timePasses();
System.out.println(star);
states.add(star.getMemento());
star.timePasses();
System.out.println(star);
states.add(star.getMemento());
star.timePasses();
System.out.println(star);
while (states.size() > 0) {
star.setMemento(states.pop());
System.out.println(star);
}
}
}