mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-18 21:25:52 +00:00
31 lines
777 B
Java
31 lines
777 B
Java
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);
|
|
}
|
|
}
|
|
}
|