-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathLevel_4.java
More file actions
46 lines (41 loc) · 1.63 KB
/
Level_4.java
File metadata and controls
46 lines (41 loc) · 1.63 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
import java.util.*;
public class Level_4 {
public static void main(String[] args) {
System.out.println("Hello! I'm Duke");
System.out.println("What can I do for you?");
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
Duke bot = new Duke();
//int counter = 1;
while(!(input.equals("bye"))) {
if (input.equals("list")) {
bot.printList();
}else{
String command = input.split(" ")[0];
if(command.equals("done")){
int id = Integer.valueOf(input.split(" ")[1]);
bot.markTaskAsDone(id);
}else if(command.equals("todo")) {
input = input.split(" ",2)[1];
ToDo newTask = new ToDo(input);
bot.addToList(newTask);
//counter++;
}else if(command.equals("event")){
input = input.split(" ",2)[1];
String content = input.split("/at")[0];
String at = input.split("/at")[1];
Event newTask = new Event(content,at);
bot.addToList(newTask);
}else{
input = input.split(" ",2)[1];
String content = input.split("/by")[0];
String by= input.split("/by")[1];
Deadline newTask = new Deadline(content,by);
bot.addToList(newTask);
}
}
input = sc.nextLine();
}
System.out.println("Bye. Hope to see you again soon!");
}
}