-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathDuke.java
More file actions
46 lines (42 loc) · 1.49 KB
/
Duke.java
File metadata and controls
46 lines (42 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
44
45
46
package duke.command;
import java.util.Scanner;
public class Duke {
private static Parser parser = new Parser();
private static Ui ui = new Ui();
private static TaskList taskList = new TaskList();
private static Storage s = new Storage();
public static void running() {
s.loadFromFile(taskList);
String line;
Scanner in = new Scanner(System.in);
while (true) {
line = in.nextLine();
if (line.equals("list")) {
taskList.listOut();
} else if (line.startsWith("find")) {
taskList.find(line);
} else if (line.startsWith("done")) {
taskList.markDone(line);
} else if (line.startsWith("delete")) {
int index = parser.getIndexForDelete(line);
taskList.deleteTask(index);
} else if (line.startsWith("todo")) {
taskList.addTodo(line);
} else if (line.startsWith("deadline")) {
taskList.addDeadline(line);
} else if (line.startsWith("event")) {
taskList.addEvent(line);
} else if (line.equals("bye")) {
s.saveToFile("data/data.txt", taskList);
return;
} else {
System.out.println("☹ OOPS!!! I'm sorry, but I don't know what that means :-(");
}
}
}
public static void main(String[] args) {
ui.sayHi();
running();
ui.sayBye();
}
}