-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathUi.java
More file actions
58 lines (52 loc) · 2.17 KB
/
Ui.java
File metadata and controls
58 lines (52 loc) · 2.17 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
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.Scanner;
public class Ui {
private TaskManager taskManager;
private Scanner scanner;
public Ui(TaskManager taskManager, Scanner scanner) {
this.taskManager = taskManager;
this.scanner = scanner;
}
public void start() {
String lineBreak = " ____________________________________________________________\n";
String logo = "\n" +
" \n" +
" ,--. ,------. ,--. ,--. ,--. \n" +
",-' '-.,---.| .-. \\ ,---.| | `--',---,-' '-. \n" +
"'-. .-| .-. | | \\ | .-. | | ,--( .-'-. .-' \n" +
" | | ' '-' | '--' ' '-' | '--| .-' `)| | \n" +
" `--' `---'`-------' `---'`-----`--`----' `--' \n" +
" \n";
String greetings = lineBreak
+ logo
+ " Welcome to the toDoList Chatbot\n"
+ " What would you like to do today?\n"
+ lineBreak;
String farewell = " Bye. Hope to see you again soon!";
System.out.println(greetings);
while (true) {
String input = scanner.nextLine();
String[] command = input.split(" ");
String firstWord = command[0];
//Task t = new Task(input);
System.out.print(lineBreak);
switch (firstWord) {
case "bye":
System.out.println(farewell);
return;
case "list":
System.out.println(" Here are the tasks in your list:");
taskManager.list();
break;
case "done":
System.out.println(" Nice! I've marked this task as done: ");
int taskNumber = Integer.parseInt(command[1]);
taskManager.checkDone(taskNumber);
System.out.println(" " + taskManager.getName(taskNumber));
break;
default:
taskManager.add(input);
}
System.out.print(lineBreak);
}
}
}