-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
27 lines (19 loc) · 1.02 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package behavioral.memento;
public class Main {
public static void main(String[] args) {
TextEditorOriginator textEditorOriginator = new TextEditorOriginator();
TextMementoCaretaker textMementoCaretaker = new TextMementoCaretaker();
textEditorOriginator.type("Hello ");
textMementoCaretaker.save(textEditorOriginator);
textEditorOriginator.type("World!");
textMementoCaretaker.save(textEditorOriginator);
textEditorOriginator.type(" More text...");
System.out.println("Before undo: '" + textEditorOriginator.getText() + "'");
textMementoCaretaker.undo(textEditorOriginator);
System.out.println("After 1st undo: '" + textEditorOriginator.getText() + "'");
textMementoCaretaker.undo(textEditorOriginator);
System.out.println("After 2nd undo: '" + textEditorOriginator.getText() + "'");
textMementoCaretaker.undo(textEditorOriginator);
System.out.println("After 3rd undo: '" + textEditorOriginator.getText() + "'");
}
}