diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 2b3aebbb..26d733bf 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,36 +1,53 @@ import java.util.*; public class Duke{ + public static void printStr(String str) { + System.out.println(str); + } + public static void main(String[] args) { //DECLARE String str = "This is the\n" - + " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n\n" - + "Hello! What can I do for you?"; + + " ____ _ \n" + + "| _ \\ _ _| | _____ \n" + + "| | | | | | | |/ / _ \\\n" + + "| |_| | |_| | < __/\n" + + "|____/ \\__,_|_|\\_\\___|\n\n" + + "Hello! What can I do for you?"; Scanner scanner = new Scanner(System.in); Boolean stay = true; - List stuff = new ArrayList(); - //SHOW - System.out.println(str); - //UH OH + ArrayList stuff = new ArrayList(); + int x = 0; + + //START HERE + printStr(str); while(stay){ str = scanner.nextLine(); - switch(str){ + String[] part = str.split(" ", 2); + switch(part[0]){ case "bye": stay = false; break; + case "done": + x = Integer.parseInt(part[1]) - 1; + stuff.get(x).markAsDone(); + printStr("Nice! I've marked this task as done:"); + printStr("[" + stuff.get(x).getStatusIcon() + "] " + stuff.get(x).getDescription()); + break; case "list": - System.out.println(stuff); + printStr("Here are the tasks in your list:"); + x = 0; + for(Task t : stuff){ + x++; + printStr(x + ".[" + t.getStatusIcon() + "] " + t.getDescription()); + } break; default: - stuff.add(str); - System.out.println("added: " + str); + stuff.add(new Task(str)); + printStr("added: " + str); } } - System.out.println("Bye. Hope to see you again soon!"); + printStr("Bye. Hope to see you again soon!"); scanner.close(); } } \ No newline at end of file diff --git a/src/main/java/Task.java b/src/main/java/Task.java new file mode 100644 index 00000000..28a0640f --- /dev/null +++ b/src/main/java/Task.java @@ -0,0 +1,23 @@ +//import java.util.*; + +public class Task { + protected String description; + protected boolean isDone; + + public Task(String description) { + this.description = description; + this.isDone = false; + } + + public String getDescription() { + return this.description; + } + + public String getStatusIcon() { + return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols + } + + public void markAsDone() { + this.isDone = true; + } +} \ No newline at end of file