-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathDuke.java
More file actions
57 lines (48 loc) · 1.68 KB
/
Duke.java
File metadata and controls
57 lines (48 loc) · 1.68 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
import java.util.*;
public class Duke {
List<Task> list;
public Duke(){
this.list = new ArrayList<>();
}
public void greet(){
System.out.println("Hello! I'm Duke");
System.out.println("What can I do for you?");
}
public void echo(String input){
System.out.println(input);
}
public void addToList(Task task){
this.list.add(task);
System.out.println("Got it. I've added this task: ");
System.out.println(" " + task);
System.out.println("Now you have " + String.valueOf(this.list.size()) + " tasks in the list.");
}
public void printList(){
int counter = 1;
for(Task element:this.list){
System.out.println(String.valueOf(counter) + element);
counter++;
}
}
public void markTaskAsDone(int id){
Task task = this.list.get(id-1);
task.markDone();
System.out.println("Nice! I've marked this task as done:");
System.out.println(" [X] "+ task.content);
}
public void deleteTask(int id){
Task task = this.list.get(id-1);
this.list.remove(id-1);
System.out.println("Noted. I've removed this task: ");
System.out.println(" " + task);
System.out.println("Now you have " + String.valueOf(this.list.size()) + " tasks in the list.");
}
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
}
}