From cd6d347ee07299cffd0e226c0857325cf58d49e0 Mon Sep 17 00:00:00 2001 From: hshiah Date: Tue, 5 Sep 2023 21:50:10 +0800 Subject: [PATCH 1/8] Level-0 --- src/main/java/Duke.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 5d313334c..91f4e2d48 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,10 +1,17 @@ public class Duke { public static void main(String[] args) { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); +// String logo = " ____ _ \n" +// + "| _ \\ _ _| | _____ \n" +// + "| | | | | | | |/ / _ \\\n" +// + "| |_| | |_| | < __/\n" +// + "|____/ \\__,_|_|\\_\\___|\n"; + String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; + String line = "_______________________________________________"; + String exit = "Bye. Hope to see you again soon!"; + System.out.println(line); + System.out.println(greet); + System.out.println(line); + System.out.println(exit); + System.out.println(line); } } From 13ec2200a3c8ea1bfd895dd3dea1d69bbc6c4591 Mon Sep 17 00:00:00 2001 From: hshiah Date: Wed, 6 Sep 2023 02:25:10 +0800 Subject: [PATCH 2/8] Week 3 changes --- src/main/java/Duke.java | 49 ++++++++++++++++++++++++++++++++++++----- src/main/java/Task.java | 25 +++++++++++++++++++++ 2 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 src/main/java/Task.java diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 91f4e2d48..61030152d 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,16 +1,55 @@ +import java.util.Scanner; +import java.util.List; +import java.util.ArrayList; public class Duke { public static void main(String[] args) { -// String logo = " ____ _ \n" -// + "| _ \\ _ _| | _____ \n" -// + "| | | | | | | |/ / _ \\\n" -// + "| |_| | |_| | < __/\n" -// + "|____/ \\__,_|_|\\_\\___|\n"; String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; String line = "_______________________________________________"; String exit = "Bye. Hope to see you again soon!"; + String listRequirements = "Here are the tasks in your list:"; + String markRequirements = "Nice! I've marked this task as done:"; + String unmarkRequirements = "OK, I've marked this task as not done yet:"; + String markFormat = "^mark \\d+$"; + String unmarkFormat = "^unmark \\d+$"; System.out.println(line); System.out.println(greet); System.out.println(line); + Scanner scanner = new Scanner(System.in); + List todoList = new ArrayList<>(); + while(true){ + String input = scanner.nextLine(); + if(input.equals("bye")){ + break; + }else if(input.equals("list")){ + System.out.println(line); + System.out.println(listRequirements); + for(int i = 0; i < todoList.size(); i++){ + System.out.println(i+1 + ".[" + todoList.get(i).getStatusIcon() + "] " + todoList.get(i).getDescription()); + } + System.out.println(line); + }else if(input.matches(markFormat)) { + int index = Integer.parseInt(input.substring(5)); + todoList.get(index-1).markAsDone(); + System.out.println(line); + System.out.println(markRequirements); + System.out.println(" [" + todoList.get(index-1).getStatusIcon() + "] " + todoList.get(index-1).getDescription()); + System.out.println(line); + }else if(input.matches(unmarkFormat)) { + int index = Integer.parseInt(input.substring(7)); + todoList.get(index-1).unmarkAsDone(); + System.out.println(line); + System.out.println(unmarkRequirements); + System.out.println(" [" + todoList.get(index-1).getStatusIcon() + "] " + todoList.get(index-1).getDescription()); + System.out.println(line); + }else{ + Task newTask = new Task(input); + todoList.add(newTask); + System.out.println(line); + System.out.println("added: " + input); + System.out.println(line); + } + } + scanner.close(); System.out.println(exit); System.out.println(line); } diff --git a/src/main/java/Task.java b/src/main/java/Task.java new file mode 100644 index 000000000..919cd9e9d --- /dev/null +++ b/src/main/java/Task.java @@ -0,0 +1,25 @@ +public class Task { + protected String description; + protected boolean isDone; + + public Task(String description) { + this.description = description; + this.isDone = false; + } + + public String getStatusIcon() { + return (isDone ? "X" : " "); // mark done task with X + } + + public void markAsDone() { + this.isDone = true; + } + + public void unmarkAsDone(){ + this.isDone = false; + } + + public String getDescription(){ + return this.description; + } +} From 18f70b5faf473ab9430ed93c187e4ffdcd720463 Mon Sep 17 00:00:00 2001 From: hshiah Date: Sun, 17 Sep 2023 15:13:52 +0800 Subject: [PATCH 3/8] Level 5 --- src/main/java/Deadline.java | 13 ++++++ src/main/java/Duke.java | 70 ++++++++++++++++++++++++-------- src/main/java/DukeException.java | 9 ++++ src/main/java/Event.java | 19 +++++++++ src/main/java/Task.java | 12 ++++-- src/main/java/Todo.java | 10 +++++ 6 files changed, 112 insertions(+), 21 deletions(-) create mode 100644 src/main/java/Deadline.java create mode 100644 src/main/java/DukeException.java create mode 100644 src/main/java/Event.java create mode 100644 src/main/java/Todo.java diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java new file mode 100644 index 000000000..ff2164bdd --- /dev/null +++ b/src/main/java/Deadline.java @@ -0,0 +1,13 @@ +public class Deadline extends Task{ + protected String by; + + public Deadline(String description, String by) throws DukeException{ + super(description); + this.by = by; + } + + @Override + public String toString() { + return "[D]" + super.toString() + " (by: " + by + ")"; + } +} diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 61030152d..d900aaeea 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -2,9 +2,15 @@ import java.util.List; import java.util.ArrayList; public class Duke { + protected final static String line = "_______________________________________________"; + private static void print(String message){ + System.out.println(line); + System.out.println(message); + System.out.println(line); + } public static void main(String[] args) { String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; - String line = "_______________________________________________"; + //String line = "_______________________________________________"; String exit = "Bye. Hope to see you again soon!"; String listRequirements = "Here are the tasks in your list:"; String markRequirements = "Nice! I've marked this task as done:"; @@ -24,29 +30,59 @@ public static void main(String[] args) { System.out.println(line); System.out.println(listRequirements); for(int i = 0; i < todoList.size(); i++){ - System.out.println(i+1 + ".[" + todoList.get(i).getStatusIcon() + "] " + todoList.get(i).getDescription()); + System.out.println(i+1 + "." + todoList.get(i)); } System.out.println(line); }else if(input.matches(markFormat)) { int index = Integer.parseInt(input.substring(5)); - todoList.get(index-1).markAsDone(); - System.out.println(line); - System.out.println(markRequirements); - System.out.println(" [" + todoList.get(index-1).getStatusIcon() + "] " + todoList.get(index-1).getDescription()); - System.out.println(line); + try{ + todoList.get(index-1).unmarkAsDone(); + }catch(IndexOutOfBoundsException e){ + print("☹ OOPS!!! The task number is not in the list."); + continue; + } + print(markRequirements+"\n "+todoList.get(index-1)); }else if(input.matches(unmarkFormat)) { int index = Integer.parseInt(input.substring(7)); - todoList.get(index-1).unmarkAsDone(); - System.out.println(line); - System.out.println(unmarkRequirements); - System.out.println(" [" + todoList.get(index-1).getStatusIcon() + "] " + todoList.get(index-1).getDescription()); - System.out.println(line); + try{ + todoList.get(index-1).unmarkAsDone(); + }catch(IndexOutOfBoundsException e){ + print("☹ OOPS!!! The task number is not in the list."); + continue; + } + print(unmarkRequirements+"\n "+todoList.get(index-1)); + }else if(input.split(" ")[0].equals("todo")){ + Todo todo; + try{ + todo = new Todo(input.substring(4, input.length())); + }catch(DukeException e){ + continue; + } + todoList.add(todo); + print("Got it. I've added this task:\n "+todo+"\nNow you have " + todoList.size() + " tasks in the list."); + }else if(input.split(" ")[0].equals("deadline")){ + Deadline deadline; + try { + deadline = new Deadline(input.split("/")[0].substring(9, input.split("/")[0].length() - 1), input.split("/")[1].replace("by ", "")); + }catch (DukeException e){ + continue; + } + todoList.add(deadline); + print("Got it. I've added this task:\n "+deadline+"\nNow you have " + todoList.size() + " tasks in the list."); + }else if(input.split(" ")[0].equals("event")){ + Event event; + try{ + event = new Event(input.split("/")[0].substring(5, input.split("/")[0].length()-1), input.split("/")[1], input.split("/")[2]); + }catch(DukeException e){ + continue; + }catch(StringIndexOutOfBoundsException e){ + print("☹ OOPS!!! The description of a event should use \\ mark start time and end time."); + continue; + } + todoList.add(event); + print("Got it. I've added this task:\n "+event+"\nNow you have " + todoList.size() + " tasks in the list."); }else{ - Task newTask = new Task(input); - todoList.add(newTask); - System.out.println(line); - System.out.println("added: " + input); - System.out.println(line); + print("☹ OOPS!!! I'm sorry, but I don't know what that means :-("); } } scanner.close(); diff --git a/src/main/java/DukeException.java b/src/main/java/DukeException.java new file mode 100644 index 000000000..d75ff6c4b --- /dev/null +++ b/src/main/java/DukeException.java @@ -0,0 +1,9 @@ +public class DukeException extends Exception{ + protected String line = "_______________________________________________"; + public DukeException(String message){ + super(message); + System.out.println(line); + System.out.println(message); + System.out.println(line); + } +} diff --git a/src/main/java/Event.java b/src/main/java/Event.java new file mode 100644 index 000000000..50ae9ab49 --- /dev/null +++ b/src/main/java/Event.java @@ -0,0 +1,19 @@ +public class Event extends Task{ + protected String by; + protected String from; + public Event(String description, String from, String by) throws DukeException{ + super(description); + if(!from.contains("from ")){ + throw new DukeException("☹ OOPS!!! The description of a event must contain \"from\" time."); + }else if(!by.contains("to ")){ + throw new DukeException("☹ OOPS!!! The description of a event must contain \"to\" time."); + } + this.from = from; + this.by = by; + } + + @Override + public String toString() { + return "[E]" + super.toString() + " (from: " + this.from + " to: " + this.by + ")"; + } +} diff --git a/src/main/java/Task.java b/src/main/java/Task.java index 919cd9e9d..72b02518e 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -1,8 +1,11 @@ -public class Task { +public class Task{ protected String description; protected boolean isDone; - public Task(String description) { + public Task(String description) throws DukeException { + if(description.isBlank()){ + throw new DukeException("☹ OOPS!!! The description of a task cannot be empty."); + } this.description = description; this.isDone = false; } @@ -19,7 +22,8 @@ public void unmarkAsDone(){ this.isDone = false; } - public String getDescription(){ - return this.description; + @Override + public String toString() { + return "[" + getStatusIcon() + "]" + this.description; } } diff --git a/src/main/java/Todo.java b/src/main/java/Todo.java new file mode 100644 index 000000000..575da891c --- /dev/null +++ b/src/main/java/Todo.java @@ -0,0 +1,10 @@ +public class Todo extends Task{ + public Todo(String description) throws DukeException{ + super(description); + } + + @Override + public String toString() { + return "[T]" + super.toString(); + } +} From 71a2724defa07f9a8474af576ba8a513ba8d85e0 Mon Sep 17 00:00:00 2001 From: hshiah Date: Mon, 18 Sep 2023 21:42:27 +0800 Subject: [PATCH 4/8] Code Improvement --- src/main/java/Duke.java | 42 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index d900aaeea..6708904fd 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -2,38 +2,34 @@ import java.util.List; import java.util.ArrayList; public class Duke { - protected final static String line = "_______________________________________________"; + protected final static String LINE = "_______________________________________________"; + protected final static String GREET = "Hello! I'm Elwin\n" + "What can I do for you?"; + protected final static String EXIT = "Bye. Hope to see you again soon!"; + protected final static String LIST = "Here are the tasks in your list:"; + protected final static String MARK = "Nice! I've marked this task as done:"; + protected final static String UNMARK = "OK, I've marked this task as not done yet:"; + private static void print(String message){ - System.out.println(line); + System.out.println(LINE); System.out.println(message); - System.out.println(line); + System.out.println(LINE); } public static void main(String[] args) { - String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; - //String line = "_______________________________________________"; - String exit = "Bye. Hope to see you again soon!"; - String listRequirements = "Here are the tasks in your list:"; - String markRequirements = "Nice! I've marked this task as done:"; - String unmarkRequirements = "OK, I've marked this task as not done yet:"; - String markFormat = "^mark \\d+$"; - String unmarkFormat = "^unmark \\d+$"; - System.out.println(line); - System.out.println(greet); - System.out.println(line); Scanner scanner = new Scanner(System.in); List todoList = new ArrayList<>(); + print(GREET); while(true){ String input = scanner.nextLine(); if(input.equals("bye")){ break; }else if(input.equals("list")){ - System.out.println(line); - System.out.println(listRequirements); + System.out.println(LINE); + System.out.println(LIST); for(int i = 0; i < todoList.size(); i++){ System.out.println(i+1 + "." + todoList.get(i)); } - System.out.println(line); - }else if(input.matches(markFormat)) { + System.out.println(LINE); + }else if(input.matches("^mark \\d+$")) { int index = Integer.parseInt(input.substring(5)); try{ todoList.get(index-1).unmarkAsDone(); @@ -41,8 +37,8 @@ public static void main(String[] args) { print("☹ OOPS!!! The task number is not in the list."); continue; } - print(markRequirements+"\n "+todoList.get(index-1)); - }else if(input.matches(unmarkFormat)) { + print(MARK+"\n "+todoList.get(index-1)); + }else if(input.matches("^unmark \\d+$")) { int index = Integer.parseInt(input.substring(7)); try{ todoList.get(index-1).unmarkAsDone(); @@ -50,7 +46,7 @@ public static void main(String[] args) { print("☹ OOPS!!! The task number is not in the list."); continue; } - print(unmarkRequirements+"\n "+todoList.get(index-1)); + print(UNMARK+"\n "+todoList.get(index-1)); }else if(input.split(" ")[0].equals("todo")){ Todo todo; try{ @@ -86,7 +82,7 @@ public static void main(String[] args) { } } scanner.close(); - System.out.println(exit); - System.out.println(line); + System.out.println(EXIT); + System.out.println(LINE); } } From 69f1c6ccb70c333a57e208c414b1c73fb23caedd Mon Sep 17 00:00:00 2001 From: hshiah Date: Thu, 21 Sep 2023 03:11:40 +0800 Subject: [PATCH 5/8] Add increment level 6 and 7. --- src/main/java/Deadline.java | 12 +++- src/main/java/Duke.java | 97 ++++++++++++++++++++++++++++---- src/main/java/DukeException.java | 6 +- src/main/java/Event.java | 14 ++++- src/main/java/Task.java | 8 ++- src/main/java/Todo.java | 5 ++ 6 files changed, 124 insertions(+), 18 deletions(-) diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java index ff2164bdd..a5368d39f 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/Deadline.java @@ -3,11 +3,21 @@ public class Deadline extends Task{ public Deadline(String description, String by) throws DukeException{ super(description); - this.by = by; + if(!by.contains("by ")){ + throw new DukeException("☹ OOPS!!! The description of a deadline must contain \"by\" time."); + }else if(by.replace("by ", "").isBlank()){ + throw new DukeException("☹ OOPS!!! The time of a deadline cannot be empty."); + } + this.by = by.replace("by ", ""); } @Override public String toString() { return "[D]" + super.toString() + " (by: " + by + ")"; } + + @Override + public String toFile(){ + return "D | " + super.toFile() + " | " + this.by; + } } diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 6708904fd..a79c76124 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,6 +1,10 @@ +import java.io.FileReader; import java.util.Scanner; import java.util.List; import java.util.ArrayList; +import java.io.FileWriter; +import java.io.IOException; +import java.io.File; public class Duke { protected final static String LINE = "_______________________________________________"; protected final static String GREET = "Hello! I'm Elwin\n" + "What can I do for you?"; @@ -14,9 +18,55 @@ private static void print(String message){ System.out.println(message); System.out.println(LINE); } + private static void writeToFile(List list){ + try{ + FileWriter fileWriter = new FileWriter("./data/duke.txt"); + for(Task task : list){ + fileWriter.write(task.toFile()+"\n"); + } + fileWriter.flush(); + fileWriter.close(); + }catch(IOException e){ + System.out.println("Something went wrong: " + e.getMessage()); + } + } + public static void main(String[] args) { Scanner scanner = new Scanner(System.in); - List todoList = new ArrayList<>(); + List todoList = new ArrayList(); + try{ + FileReader fileReader = new FileReader("./data/duke.txt"); + Scanner fileScanner = new Scanner(fileReader); + while(fileScanner.hasNextLine()){ + String line = fileScanner.nextLine(); + if(line.equals("\n")){ + break; + } + String[] task = line.split(" \\| "); + if(task[0].equals("T")){ + todoList.add(new Todo (task[2])); + }else if(task[0].equals("D")){ + todoList.add(new Deadline (task[2], "by "+task[3])); + }else if(task[0].equals("E")){ + todoList.add(new Event (task[2], "from "+task[3], "to "+task[4])); + } + if(task[1].equals("1")){ + todoList.get(todoList.size()-1).markAsDone(); + } + } + fileScanner.close(); + fileReader.close(); + }catch(IOException e){ + try{ + File file = new File("./data/duke.txt"); + file.getParentFile().mkdirs(); + file.createNewFile(); + }catch(IOException ex){ + System.out.println("☹ OOPS!!! The file has existed."); + } + }catch(DukeException e){ + System.out.println("☹ OOPS!!! Wrong format in file."); + } print(GREET); while(true){ String input = scanner.nextLine(); @@ -32,11 +82,12 @@ public static void main(String[] args) { }else if(input.matches("^mark \\d+$")) { int index = Integer.parseInt(input.substring(5)); try{ - todoList.get(index-1).unmarkAsDone(); + todoList.get(index-1).markAsDone(); }catch(IndexOutOfBoundsException e){ print("☹ OOPS!!! The task number is not in the list."); continue; } + writeToFile(todoList); print(MARK+"\n "+todoList.get(index-1)); }else if(input.matches("^unmark \\d+$")) { int index = Integer.parseInt(input.substring(7)); @@ -46,37 +97,63 @@ public static void main(String[] args) { print("☹ OOPS!!! The task number is not in the list."); continue; } + writeToFile(todoList); print(UNMARK+"\n "+todoList.get(index-1)); }else if(input.split(" ")[0].equals("todo")){ Todo todo; try{ - todo = new Todo(input.substring(4, input.length())); + todo = new Todo(input.substring(5, input.length())); }catch(DukeException e){ continue; + }catch(StringIndexOutOfBoundsException e){ + print("☹ OOPS!!! The description of a todo cannot be empty."); + continue; } todoList.add(todo); + writeToFile(todoList); print("Got it. I've added this task:\n "+todo+"\nNow you have " + todoList.size() + " tasks in the list."); }else if(input.split(" ")[0].equals("deadline")){ Deadline deadline; try { - deadline = new Deadline(input.split("/")[0].substring(9, input.split("/")[0].length() - 1), input.split("/")[1].replace("by ", "")); + deadline = new Deadline(input.split(" /")[0].substring(9), input.split(" /")[1]); }catch (DukeException e){ continue; + }catch (ArrayIndexOutOfBoundsException e){ + print("☹ OOPS!!! The description of a deadline should use / mark time."); + continue; + }catch(StringIndexOutOfBoundsException e){ + print("☹ OOPS!!! The description of a deadline cannot be empty."); + continue; } todoList.add(deadline); + writeToFile(todoList); print("Got it. I've added this task:\n "+deadline+"\nNow you have " + todoList.size() + " tasks in the list."); - }else if(input.split(" ")[0].equals("event")){ + }else if(input.split(" ")[0].equals("event")) { Event event; - try{ - event = new Event(input.split("/")[0].substring(5, input.split("/")[0].length()-1), input.split("/")[1], input.split("/")[2]); - }catch(DukeException e){ + try { + event = new Event(input.split(" /")[0].substring(6), input.split(" /")[1], input.split(" /")[2]); + }catch(DukeException e) { + continue; + }catch(ArrayIndexOutOfBoundsException e) { + print("☹ OOPS!!! The description of a event should use / mark start time and end time."); continue; }catch(StringIndexOutOfBoundsException e){ - print("☹ OOPS!!! The description of a event should use \\ mark start time and end time."); + print("☹ OOPS!!! The description of a event cannot be empty."); continue; } + writeToFile(todoList); todoList.add(event); - print("Got it. I've added this task:\n "+event+"\nNow you have " + todoList.size() + " tasks in the list."); + print("Got it. I've added this task:\n " + event + "\nNow you have " + todoList.size() + " tasks in the list."); + }else if(input.split(" ")[0].equals("delete")){ + int index = Integer.parseInt(input.substring(7)); + try{ + Task task = todoList.get(index-1); + todoList.remove(index-1); + writeToFile(todoList); + print("Noted. I've removed this task:\n "+task+"\nNow you have " + todoList.size() + " tasks in the list."); + }catch(IndexOutOfBoundsException e){ + print("☹ OOPS!!! The task number is not in the list."); + } }else{ print("☹ OOPS!!! I'm sorry, but I don't know what that means :-("); } diff --git a/src/main/java/DukeException.java b/src/main/java/DukeException.java index d75ff6c4b..21caf9b0b 100644 --- a/src/main/java/DukeException.java +++ b/src/main/java/DukeException.java @@ -1,9 +1,9 @@ public class DukeException extends Exception{ - protected String line = "_______________________________________________"; + protected String LINE = "_______________________________________________"; public DukeException(String message){ super(message); - System.out.println(line); + System.out.println(LINE); System.out.println(message); - System.out.println(line); + System.out.println(LINE); } } diff --git a/src/main/java/Event.java b/src/main/java/Event.java index 50ae9ab49..583738cda 100644 --- a/src/main/java/Event.java +++ b/src/main/java/Event.java @@ -7,13 +7,23 @@ public Event(String description, String from, String by) throws DukeException{ throw new DukeException("☹ OOPS!!! The description of a event must contain \"from\" time."); }else if(!by.contains("to ")){ throw new DukeException("☹ OOPS!!! The description of a event must contain \"to\" time."); + }else if(from.replace("from ", "").isBlank()){ + throw new DukeException("☹ OOPS!!! The start time of a event cannot be empty."); + }else if(by.replace("to ", "").isBlank()){ + throw new DukeException("☹ OOPS!!! The end time of a event cannot be empty."); } - this.from = from; - this.by = by; + this.from = from.replace("from ", ""); + this.by = by.replace("to ", ""); } @Override public String toString() { return "[E]" + super.toString() + " (from: " + this.from + " to: " + this.by + ")"; } + + + @Override + public String toFile(){ + return "E | " + super.toFile() + " | " + this.from + " | " + this.by; + } } diff --git a/src/main/java/Task.java b/src/main/java/Task.java index 72b02518e..477076686 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -11,7 +11,7 @@ public Task(String description) throws DukeException { } public String getStatusIcon() { - return (isDone ? "X" : " "); // mark done task with X + return (isDone ? "X" : " "); } public void markAsDone() { @@ -24,6 +24,10 @@ public void unmarkAsDone(){ @Override public String toString() { - return "[" + getStatusIcon() + "]" + this.description; + return "[" + getStatusIcon() + "] " + this.description; + } + + public String toFile(){ + return (isDone ? "1" : "0") + " | " + this.description; } } diff --git a/src/main/java/Todo.java b/src/main/java/Todo.java index 575da891c..052b213d1 100644 --- a/src/main/java/Todo.java +++ b/src/main/java/Todo.java @@ -7,4 +7,9 @@ public Todo(String description) throws DukeException{ public String toString() { return "[T]" + super.toString(); } + + @Override + public String toFile(){ + return "T | " + super.toFile(); + } } From 4d8d6eca7be9f60b4bbef11ba552e586645958ef Mon Sep 17 00:00:00 2001 From: hshiah Date: Fri, 6 Oct 2023 19:10:14 +0800 Subject: [PATCH 6/8] update README --- docs/README.md | 141 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 127 insertions(+), 14 deletions(-) diff --git a/docs/README.md b/docs/README.md index 8077118eb..da752f906 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,29 +1,142 @@ -# User Guide +# User Guide of Elvin -## Features +This is Elvin, the best personal task management system you will ever use! -### Feature-ABC +## Quick Start -Description of the feature. +1. Ensure that you have `Java 11` installed on your laptop or computer. +2. Download the latest version of the JAR file. +3. Move the file to a folder that you want to use for the application +4. Open up CLI and traverse until you reach your app folder. +5. Type in `java -jar "Elvin.jar"`. +6. The app will create a data folder and text file and it will close again. -### Feature-XYZ +## Features -Description of the feature. +### Add Todo : `todo` -## Usage +Add a todo task to the the list of tasks. -### `Keyword` - Describe action +**Format:** `todo DESCRIPTION` -Describe the action and its outcome. +Example: -Example of usage: +``` +todo borrow book +``` + + +### Add Deadline : `deadline` + +Add a deadline task to the list of task with specific deadline. + +**Format:** `deadline DESCRIPTION /by DEADLINE` + + +Example: + +``` +deadline homework /by Sunday +``` + + +### Add Event : `event` + +Add a event task to the list of task with a time period marked by from and to. + +**Format:** `event DESCRIPTION /from START /to END` + +Example: + +``` +event midterm exam /from 15:00 /to 17:00 +``` + + +### Delete Task : `delete` + +Delete task from list of task based on index. + +**Format:** `delete INDEX` + +Example: + +``` +delete 2 +``` + + +### List Task : `list` + +List all tasks in the list of tasks. + +**Format:** `list` + +Example: -`keyword (optional arguments)` +``` +list +``` + + +### Mark Task : `mark` + +Mark a task as done based on index. + +**Format:** `mark INDEX` + +Example: + +``` +mark 2 +``` + + +### Unmark Task : `unmark` + +Unmark a task as done based on index. + +**Format:** `unmark INDEX` + +Example: + +``` +unmark 5 +``` + + +### Find Task : `find` + +List all tasks that contains the given string + +**Format:** `find DESCRIPTION` + +Example: + +``` +find book +``` + +### EXIT : `bye` + +Exit the app -Expected outcome: +**Format:** `bye` -Description of the outcome. + +Example: ``` -expected output +bye ``` + +### Save Data +The data is saved in the hard disk automatically after any command that changes the data. There is no need to save manually. + +### Edit Data +The data is edited in the hard disk automatically after any command that changes the data. +If you want to edit the data manually, you can use the app to edit it. + +## FAQ +Q: How do I transfer my data to another Computer? +A: Install the app in the other computer and overwrite the empty data file it creates with the file that contains the data of your previous Elvin folder with same relative location. From faddc9e3aca7de6aa4adfc5e2c84ccbd0a357b81 Mon Sep 17 00:00:00 2001 From: hshiah Date: Fri, 6 Oct 2023 19:31:18 +0800 Subject: [PATCH 7/8] Level-9 --- src/main/java/Deadline.java | 20 +++- src/main/java/Duke.java | 165 ------------------------------- src/main/java/DukeException.java | 4 +- src/main/java/Elvin.java | 90 +++++++++++++++++ src/main/java/Event.java | 25 +++-- src/main/java/Parser.java | 59 +++++++++++ src/main/java/Storage.java | 61 ++++++++++++ src/main/java/Task.java | 29 +++++- src/main/java/TaskList.java | 78 +++++++++++++++ src/main/java/Todo.java | 2 +- src/main/java/Ui.java | 98 ++++++++++++++++++ 11 files changed, 446 insertions(+), 185 deletions(-) delete mode 100644 src/main/java/Duke.java create mode 100644 src/main/java/Elvin.java create mode 100644 src/main/java/Parser.java create mode 100644 src/main/java/Storage.java create mode 100644 src/main/java/TaskList.java create mode 100644 src/main/java/Ui.java diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java index a5368d39f..106005371 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/Deadline.java @@ -1,23 +1,33 @@ -public class Deadline extends Task{ +public class Deadline extends Task { protected String by; - public Deadline(String description, String by) throws DukeException{ + public Deadline(String description, String by) throws DukeException { super(description); - if(!by.contains("by ")){ + if(!by.contains("by ")) { throw new DukeException("☹ OOPS!!! The description of a deadline must contain \"by\" time."); - }else if(by.replace("by ", "").isBlank()){ + }else if(by.replace("by ", "").isBlank()) { throw new DukeException("☹ OOPS!!! The time of a deadline cannot be empty."); } this.by = by.replace("by ", ""); } + /** + * Converts the Deadline object into a string. + * + * @return String format of the object. + */ @Override public String toString() { return "[D]" + super.toString() + " (by: " + by + ")"; } + /** + * Converts the object into a string to be stored in file. + * + * @return String format of the object to be stored in file. + */ @Override - public String toFile(){ + public String toFile() { return "D | " + super.toFile() + " | " + this.by; } } diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java deleted file mode 100644 index a79c76124..000000000 --- a/src/main/java/Duke.java +++ /dev/null @@ -1,165 +0,0 @@ -import java.io.FileReader; -import java.util.Scanner; -import java.util.List; -import java.util.ArrayList; -import java.io.FileWriter; -import java.io.IOException; -import java.io.File; -public class Duke { - protected final static String LINE = "_______________________________________________"; - protected final static String GREET = "Hello! I'm Elwin\n" + "What can I do for you?"; - protected final static String EXIT = "Bye. Hope to see you again soon!"; - protected final static String LIST = "Here are the tasks in your list:"; - protected final static String MARK = "Nice! I've marked this task as done:"; - protected final static String UNMARK = "OK, I've marked this task as not done yet:"; - - private static void print(String message){ - System.out.println(LINE); - System.out.println(message); - System.out.println(LINE); - } - private static void writeToFile(List list){ - try{ - FileWriter fileWriter = new FileWriter("./data/duke.txt"); - for(Task task : list){ - fileWriter.write(task.toFile()+"\n"); - } - fileWriter.flush(); - fileWriter.close(); - }catch(IOException e){ - System.out.println("Something went wrong: " + e.getMessage()); - } - } - - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - List todoList = new ArrayList(); - try{ - FileReader fileReader = new FileReader("./data/duke.txt"); - Scanner fileScanner = new Scanner(fileReader); - while(fileScanner.hasNextLine()){ - String line = fileScanner.nextLine(); - if(line.equals("\n")){ - break; - } - String[] task = line.split(" \\| "); - if(task[0].equals("T")){ - todoList.add(new Todo (task[2])); - }else if(task[0].equals("D")){ - todoList.add(new Deadline (task[2], "by "+task[3])); - }else if(task[0].equals("E")){ - todoList.add(new Event (task[2], "from "+task[3], "to "+task[4])); - } - if(task[1].equals("1")){ - todoList.get(todoList.size()-1).markAsDone(); - } - } - fileScanner.close(); - fileReader.close(); - }catch(IOException e){ - try{ - File file = new File("./data/duke.txt"); - file.getParentFile().mkdirs(); - file.createNewFile(); - }catch(IOException ex){ - System.out.println("☹ OOPS!!! The file has existed."); - } - }catch(DukeException e){ - System.out.println("☹ OOPS!!! Wrong format in file."); - } - print(GREET); - while(true){ - String input = scanner.nextLine(); - if(input.equals("bye")){ - break; - }else if(input.equals("list")){ - System.out.println(LINE); - System.out.println(LIST); - for(int i = 0; i < todoList.size(); i++){ - System.out.println(i+1 + "." + todoList.get(i)); - } - System.out.println(LINE); - }else if(input.matches("^mark \\d+$")) { - int index = Integer.parseInt(input.substring(5)); - try{ - todoList.get(index-1).markAsDone(); - }catch(IndexOutOfBoundsException e){ - print("☹ OOPS!!! The task number is not in the list."); - continue; - } - writeToFile(todoList); - print(MARK+"\n "+todoList.get(index-1)); - }else if(input.matches("^unmark \\d+$")) { - int index = Integer.parseInt(input.substring(7)); - try{ - todoList.get(index-1).unmarkAsDone(); - }catch(IndexOutOfBoundsException e){ - print("☹ OOPS!!! The task number is not in the list."); - continue; - } - writeToFile(todoList); - print(UNMARK+"\n "+todoList.get(index-1)); - }else if(input.split(" ")[0].equals("todo")){ - Todo todo; - try{ - todo = new Todo(input.substring(5, input.length())); - }catch(DukeException e){ - continue; - }catch(StringIndexOutOfBoundsException e){ - print("☹ OOPS!!! The description of a todo cannot be empty."); - continue; - } - todoList.add(todo); - writeToFile(todoList); - print("Got it. I've added this task:\n "+todo+"\nNow you have " + todoList.size() + " tasks in the list."); - }else if(input.split(" ")[0].equals("deadline")){ - Deadline deadline; - try { - deadline = new Deadline(input.split(" /")[0].substring(9), input.split(" /")[1]); - }catch (DukeException e){ - continue; - }catch (ArrayIndexOutOfBoundsException e){ - print("☹ OOPS!!! The description of a deadline should use / mark time."); - continue; - }catch(StringIndexOutOfBoundsException e){ - print("☹ OOPS!!! The description of a deadline cannot be empty."); - continue; - } - todoList.add(deadline); - writeToFile(todoList); - print("Got it. I've added this task:\n "+deadline+"\nNow you have " + todoList.size() + " tasks in the list."); - }else if(input.split(" ")[0].equals("event")) { - Event event; - try { - event = new Event(input.split(" /")[0].substring(6), input.split(" /")[1], input.split(" /")[2]); - }catch(DukeException e) { - continue; - }catch(ArrayIndexOutOfBoundsException e) { - print("☹ OOPS!!! The description of a event should use / mark start time and end time."); - continue; - }catch(StringIndexOutOfBoundsException e){ - print("☹ OOPS!!! The description of a event cannot be empty."); - continue; - } - writeToFile(todoList); - todoList.add(event); - print("Got it. I've added this task:\n " + event + "\nNow you have " + todoList.size() + " tasks in the list."); - }else if(input.split(" ")[0].equals("delete")){ - int index = Integer.parseInt(input.substring(7)); - try{ - Task task = todoList.get(index-1); - todoList.remove(index-1); - writeToFile(todoList); - print("Noted. I've removed this task:\n "+task+"\nNow you have " + todoList.size() + " tasks in the list."); - }catch(IndexOutOfBoundsException e){ - print("☹ OOPS!!! The task number is not in the list."); - } - }else{ - print("☹ OOPS!!! I'm sorry, but I don't know what that means :-("); - } - } - scanner.close(); - System.out.println(EXIT); - System.out.println(LINE); - } -} diff --git a/src/main/java/DukeException.java b/src/main/java/DukeException.java index 21caf9b0b..e3a149d74 100644 --- a/src/main/java/DukeException.java +++ b/src/main/java/DukeException.java @@ -1,6 +1,6 @@ -public class DukeException extends Exception{ +public class DukeException extends Exception { protected String LINE = "_______________________________________________"; - public DukeException(String message){ + public DukeException(String message) { super(message); System.out.println(LINE); System.out.println(message); diff --git a/src/main/java/Elvin.java b/src/main/java/Elvin.java new file mode 100644 index 000000000..043c75885 --- /dev/null +++ b/src/main/java/Elvin.java @@ -0,0 +1,90 @@ +import java.util.ArrayList; +import java.util.Scanner; + +public class Elvin { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + TaskList tasks = new TaskList(); + Storage storage = new Storage(); + Ui ui = new Ui(); + Parser parser = new Parser(); + storage.readFromFile(tasks); + ui.printGreet(); + while(true) { + String input = scanner.nextLine(); + ArrayList parsedInput; + try { + parsedInput = parser.parse(input); + } catch(DukeException e) { + continue; + } + if(parsedInput.get(0).equals("bye")) { + break; + } else if(parsedInput.get(0).equals("list")) { + ui.printList(tasks); + } else if(parsedInput.get(0).equals("mark")) { + int index = Integer.parseInt(parsedInput.get(1)); + try { + tasks.markTask(index); + storage.writeToFile(tasks); + ui.printMark(tasks.get(index)); + } catch(IndexOutOfBoundsException e) { + ui.print("☹ OOPS!!! The index is out of bound."); + } + } else if(parsedInput.get(0).equals("unmark")) { + int index = Integer.parseInt(parsedInput.get(1)); + try { + tasks.unmarkTask(index); + storage.writeToFile(tasks); + ui.printUnmark(tasks.get(index)); + } catch(IndexOutOfBoundsException e) { + ui.print("☹ OOPS!!! The index is out of bound."); + } + } else if(parsedInput.get(0).equals("todo")) { + Todo todo; + try { + todo = new Todo(parsedInput.get(1)); + } catch(DukeException e) { + continue; + } + tasks.addTask(todo); + storage.writeToFile(tasks); + ui.printAddition(todo, tasks.size()); + } else if(parsedInput.get(0).equals("deadline")) { + Deadline deadline; + try { + deadline = new Deadline(parsedInput.get(1), parsedInput.get(2)); + } catch (DukeException e) { + continue; + } + tasks.addTask(deadline); + storage.writeToFile(tasks); + ui.printAddition(deadline, tasks.size()); + } else if(parsedInput.get(0).equals("event")) { + Event event; + try { + event = new Event(parsedInput.get(1), parsedInput.get(2), parsedInput.get(3)); + } catch(DukeException e) { + continue; + } + tasks.addTask(event); + storage.writeToFile(tasks); + ui.printAddition(event, tasks.size()); + } else if(parsedInput.get(0).equals("delete")) { + int index = Integer.parseInt(parsedInput.get(1)); + try { + ui.printDeletion(tasks.get(index), tasks.size()-1); + tasks.deleteTask(index); + storage.writeToFile(tasks); + } catch(IndexOutOfBoundsException e) { + ui.print("☹ OOPS!!! The index is out of bound."); + } + } else if(parsedInput.get(0).equals("find")) { + TaskList temp = tasks.find(parsedInput.get(1)); + ui.printList(temp); + } + } + scanner.close(); + ui.printExit(); + } +} diff --git a/src/main/java/Event.java b/src/main/java/Event.java index 583738cda..55bdcbb25 100644 --- a/src/main/java/Event.java +++ b/src/main/java/Event.java @@ -1,29 +1,38 @@ -public class Event extends Task{ +public class Event extends Task { protected String by; protected String from; - public Event(String description, String from, String by) throws DukeException{ + public Event(String description, String from, String by) throws DukeException { super(description); - if(!from.contains("from ")){ + if(!from.contains("from ")) { throw new DukeException("☹ OOPS!!! The description of a event must contain \"from\" time."); - }else if(!by.contains("to ")){ + } else if(!by.contains("to ")) { throw new DukeException("☹ OOPS!!! The description of a event must contain \"to\" time."); - }else if(from.replace("from ", "").isBlank()){ + } else if(from.replace("from ", "").isBlank()){ throw new DukeException("☹ OOPS!!! The start time of a event cannot be empty."); - }else if(by.replace("to ", "").isBlank()){ + } else if(by.replace("to ", "").isBlank()) { throw new DukeException("☹ OOPS!!! The end time of a event cannot be empty."); } this.from = from.replace("from ", ""); this.by = by.replace("to ", ""); } + /** + * Converts the Deadline object into a string. + * + * @return String format of the object. + */ @Override public String toString() { return "[E]" + super.toString() + " (from: " + this.from + " to: " + this.by + ")"; } - + /** + * Converts the object into a string to be stored in file. + * + * @return String format of the object to be stored in file. + */ @Override - public String toFile(){ + public String toFile() { return "E | " + super.toFile() + " | " + this.from + " | " + this.by; } } diff --git a/src/main/java/Parser.java b/src/main/java/Parser.java new file mode 100644 index 000000000..ac835699e --- /dev/null +++ b/src/main/java/Parser.java @@ -0,0 +1,59 @@ +import java.util.ArrayList; +public class Parser { + /** + * Parse the input command. + * + * @param input The input command. + * @return The parsed input. + */ + public ArrayList parse(String input) throws DukeException { + ArrayList result = new ArrayList(); + String[] temp = input.split(" "); + result.add(temp[0]); + if(temp[0].equals("todo")) { + try { + result.add(input.substring(5)); + } catch(StringIndexOutOfBoundsException e) { + throw new DukeException("☹ OOPS!!! The description of a todo cannot be empty."); + } + } else if(temp[0].equals("deadline")) { + try { + result.add(input.split(" /")[0].substring(9)); + result.add(input.split(" /")[1]); + } catch(StringIndexOutOfBoundsException e) { + throw new DukeException("☹ OOPS!!! The description of a deadline cannot be empty."); + } catch(ArrayIndexOutOfBoundsException e) { + throw new DukeException("☹ OOPS!!! The description of a deadline should use / mark time."); + } + } else if(temp[0].equals("event")) { + try { + result.add(input.split(" /")[0].substring(6)); + result.add(input.split(" /")[1]); + result.add(input.split(" /")[2]); + } catch(ArrayIndexOutOfBoundsException e) { + throw new DukeException("☹ OOPS!!! The description of a event should use / mark start time and end time."); + } catch(StringIndexOutOfBoundsException e) { + throw new DukeException("☹ OOPS!!! The description of a event cannot be empty."); + } + } else if(temp[0].equals("mark")||temp[0].equals("unmark")||temp[0].equals("delete")) { + try { + result.add(temp[1]); + } catch(ArrayIndexOutOfBoundsException e) { + throw new DukeException("☹ OOPS!!! The index of instruction " + temp[0] + " cannot be empty."); + } + } else if(temp[0].equals("find")) { + try { + result.add(input.substring(5)); + } catch (StringIndexOutOfBoundsException e) { + throw new DukeException("☹ OOPS!!! The description of a find cannot be empty."); + } + } else if(temp[0].equals("bye")||temp[0].equals("list")) { + if(temp.length!=1){ + throw new DukeException("☹ OOPS!!! The instruction " + temp[0] + " cannot have other words."); + } + } else { + throw new DukeException("☹ OOPS!!! I'm sorry, but I don't know what that means :-("); + } + return result; + } +} diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java new file mode 100644 index 000000000..7001eceef --- /dev/null +++ b/src/main/java/Storage.java @@ -0,0 +1,61 @@ +import java.io.FileWriter; +import java.io.IOException; +import java.io.File; +import java.io.FileReader; +import java.util.Scanner; +public class Storage { + /** + * Write the task list to the file + * + * @param tasks The task list to be written to the file + */ + public void writeToFile(TaskList tasks) { + try { + FileWriter fw = new FileWriter("data/duke.txt"); + for (int i=0;i tasks; + public TaskList(){ + this.tasks = new ArrayList(); + } + + /** + * Add the task to the list + * + * @param task The task list to be added to the list + */ + public void addTask(Task task){ + this.tasks.add(task); + } + + /** + * Delete the task with the index + * + * @param index The index of task to be deleted + */ + public void deleteTask(int index) throws IndexOutOfBoundsException{ + this.tasks.remove(index-1); + } + + /** + * Mark the task with the index as done + * + * @param index The index of task to be marked as done + */ + public void markTask(int index) throws IndexOutOfBoundsException{ + this.tasks.get(index-1).markAsDone(); + } + + /** + * Unark the task with the index as done + * + * @param index The index of task to be unmarked as done + */ + public void unmarkTask(int index) throws IndexOutOfBoundsException{ + this.tasks.get(index-1).unmarkAsDone(); + } + + /** + * Find the task with the description + * + * @param description The description of task to be found + * @return The task list with the description + */ + public TaskList find(String description){ + TaskList temp = new TaskList(); + for(Task task : this.tasks){ + if(task.toString().contains(description)){ + temp.addTask(task); + } + } + return temp; + } + + /** + * Get the task with the index + * + * @param index The index of task to be get + * @return The task with the index + */ + public Task get(int index){ + return this.tasks.get(index-1); + } + + /** + * Get the size of the list + * + * @return The size of the list + */ + public int size(){ + return this.tasks.size(); + } +} diff --git a/src/main/java/Todo.java b/src/main/java/Todo.java index 052b213d1..d3759490e 100644 --- a/src/main/java/Todo.java +++ b/src/main/java/Todo.java @@ -9,7 +9,7 @@ public String toString() { } @Override - public String toFile(){ + public String toFile() { return "T | " + super.toFile(); } } diff --git a/src/main/java/Ui.java b/src/main/java/Ui.java new file mode 100644 index 000000000..737b7bcef --- /dev/null +++ b/src/main/java/Ui.java @@ -0,0 +1,98 @@ +public class Ui { + protected final static String LINE = "_______________________________________________"; + protected final static String GREET = "Hello! I'm Elwin\n" + "What can I do for you?"; + protected final static String EXIT = "Bye. Hope to see you again soon!"; + protected final static String LIST = "Here are the tasks in your list:"; + protected final static String MARK = "Nice! I've marked this task as done:"; + protected final static String UNMARK = "OK, I've marked this task as not done yet:"; + protected final static String FIND = "Here are the matching tasks in your list:"; + /** + * Print the message + * + * @param message The message to be printed + */ + public void print(String message) { + System.out.println(LINE); + System.out.println(message); + System.out.println(LINE); + } + + /** + * Print the list of tasks + * + * @param tasks the task list + */ + public void printList(TaskList tasks) { + System.out.println(LINE); + System.out.println(LIST); + for(int i = 0; i < tasks.size(); i++){ + System.out.println((i+1) + "." + tasks.get(i+1).toString()); + } + System.out.println(LINE); + } + + /** + * Print the list of found tasks + * + * @param tasks the task list + */ + public void printFoundTasks(TaskList tasks) { + System.out.println(LINE); + System.out.println(FIND); + for(int i = 0; i < tasks.size(); i++){ + System.out.println((i+1) + "." + tasks.get(i+1).toString()); + } + System.out.println(LINE); + } + /** + * Print when the task is marked as done + * + * @param task The task which is marked as done + */ + public void printMark(Task task) { + print(UNMARK+"\n "+task.toString()); + } + + /** + * Print when the task is unmarked as done + * + * @param task The task which is unmarked as done + */ + public void printUnmark(Task task) { + print(MARK+"\n "+task.toString()); + } + + /** + * Print the greet message + */ + public void printGreet() { + print(GREET); + } + + /** + * Print the exit message + */ + public void printExit() { + print(EXIT); + } + + /** + * Print the message when one task is added + * + * @param task The task which is added + * @param size The size of the list + */ + public void printAddition(Task task, int size) { + print("Got it. I've added this task:\n "+task.toString()+"\nNow you have "+size+" tasks in the list."); + } + + /** + * Print the message when one task is deleted + * + * @param task The task which is deleted + * @param size The size of the list + */ + public void printDeletion(Task task, int size) { + print("Noted. I've removed this task:\n "+task.toString()+"\nNow you have "+size+" tasks in the list."); + } +} From b800f93e92d628b8b9c89e896ec07c87ceedcb65 Mon Sep 17 00:00:00 2001 From: hshiah Date: Mon, 9 Oct 2023 18:26:04 +0800 Subject: [PATCH 8/8] Fix wrong output for find task. --- src/main/java/Elvin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Elvin.java b/src/main/java/Elvin.java index 043c75885..78564aaa9 100644 --- a/src/main/java/Elvin.java +++ b/src/main/java/Elvin.java @@ -81,7 +81,7 @@ public static void main(String[] args) { } } else if(parsedInput.get(0).equals("find")) { TaskList temp = tasks.find(parsedInput.get(1)); - ui.printList(temp); + ui.printFoundTasks(temp); } } scanner.close();