This repository was archived by the owner on Mar 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestMain.java
More file actions
43 lines (41 loc) · 1.49 KB
/
Copy pathTestMain.java
File metadata and controls
43 lines (41 loc) · 1.49 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class TestMain {
public static void main(String[] args){
Notepad notepad = new Notepad("log.txt");
try {
Scanner input = new Scanner(System.in);
while (true){
System.out.print("Commands: quit/modify/undo/redo\nEnd modifying by typing :end\n");
System.out.print(notepad.toString());
System.out.print("Command: ");
String command = input.nextLine();
switch(command){
case "quit":
return;
case "modify":
StringBuilder newText = new StringBuilder();
String currentLine = input.nextLine();
while (!currentLine.equals(":end")) {
newText.append(currentLine);
newText.append("\n");
currentLine = input.nextLine();
}
notepad.save(newText.toString());
break;
case "undo":
notepad.undo();
break;
case "redo":
notepad.redo();
break;
}
}
}
catch(IOException e){
e.printStackTrace();
}
}
}