-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
23 lines (18 loc) · 735 Bytes
/
Main.java
File metadata and controls
23 lines (18 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package design_patterns.behavioral.momento_pattern;
public class Main {
public static void main(String[] args) {
Editor editor = new Editor();
History history = new History();
editor.setContent("Version 1");
history.push(editor.createState());
editor.setContent("Version 2");
history.push(editor.createState());
editor.setContent("Version 3");
editor.restore(history.pop());
System.out.println("Restored to: " + editor.getContent());
editor.restore(history.pop());
System.out.println("Restored to: " + editor.getContent());
editor.restore(history.pop());
System.out.println("Restored to: " + editor.getContent());
}
}