From aa5ed3de15b718e1cf3a1dac1e5e71f1b0f3f095 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Wed, 6 Sep 2023 01:31:43 +0800 Subject: [PATCH 01/86] add file "Hello.txt" --- src/main/java/Hello.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/java/Hello.txt diff --git a/src/main/java/Hello.txt b/src/main/java/Hello.txt new file mode 100644 index 000000000..e69de29bb From 28f7f8f56e447cdff4e8f89fdcb34418a125465a Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Wed, 6 Sep 2023 01:44:47 +0800 Subject: [PATCH 02/86] add new file "HelloAgain.txt" --- src/main/java/HelloAgain.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/java/HelloAgain.txt diff --git a/src/main/java/HelloAgain.txt b/src/main/java/HelloAgain.txt new file mode 100644 index 000000000..e69de29bb From 1a006bea87db09fc7d72d01b6f785c2e2e0e1a19 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 7 Sep 2023 01:47:27 +0800 Subject: [PATCH 03/86] remove the file "Hello.txt" and "HelloAgain.txt" --- src/main/java/Deadline.java | 2 ++ src/main/java/Event.java | 2 ++ src/main/java/Hello.txt | 0 src/main/java/HelloAgain.txt | 0 src/main/java/Task.java | 2 ++ src/main/java/Todo.java | 2 ++ 6 files changed, 8 insertions(+) create mode 100644 src/main/java/Deadline.java create mode 100644 src/main/java/Event.java delete mode 100644 src/main/java/Hello.txt delete mode 100644 src/main/java/HelloAgain.txt create mode 100644 src/main/java/Task.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..623a1f49d --- /dev/null +++ b/src/main/java/Deadline.java @@ -0,0 +1,2 @@ +package PACKAGE_NAME;public class Deadline { +} diff --git a/src/main/java/Event.java b/src/main/java/Event.java new file mode 100644 index 000000000..fe6147652 --- /dev/null +++ b/src/main/java/Event.java @@ -0,0 +1,2 @@ +package PACKAGE_NAME;public class Event { +} diff --git a/src/main/java/Hello.txt b/src/main/java/Hello.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/java/HelloAgain.txt b/src/main/java/HelloAgain.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/java/Task.java b/src/main/java/Task.java new file mode 100644 index 000000000..4ec445449 --- /dev/null +++ b/src/main/java/Task.java @@ -0,0 +1,2 @@ +package PACKAGE_NAME;public class Task { +} diff --git a/src/main/java/Todo.java b/src/main/java/Todo.java new file mode 100644 index 000000000..73a10cb4d --- /dev/null +++ b/src/main/java/Todo.java @@ -0,0 +1,2 @@ +package PACKAGE_NAME;public class Todo { +} From f96320359306dc0cb0fd8cb3753aa03b14036825 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 7 Sep 2023 01:49:06 +0800 Subject: [PATCH 04/86] add new file "Deadline.java" as subclass of Tast --- src/main/java/Deadline.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java index 623a1f49d..e4e4b232c 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/Deadline.java @@ -1,2 +1,14 @@ -package PACKAGE_NAME;public class Deadline { +public class Deadline extends Task { + + protected String by; + + public Deadline(String description, String by) { + super(description); + this.by = by; + } + + @Override + public String toString() { + return "[D]" + super.toString() + " (by: " + by + ")"; + } } From ce21c8cf584471efd379e5924323863d3f42ad93 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 7 Sep 2023 01:50:22 +0800 Subject: [PATCH 05/86] implement the main function Duke to finish the required tasks from lv1 - 4 --- src/main/java/Duke.java | 99 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 6 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 5d313334c..333d58fad 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,10 +1,97 @@ +import java.util.Scanner; + public class Duke { public static void main(String[] args) { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); + Scanner scanner = new Scanner(System.in); + Task[] list = new Task[100]; + int count = 0; + + System.out.println("Hello! I'm Oriento."); + System.out.println("What can I do for you?"); + + while (true) { + String command = scanner.nextLine(); + String[] parts = command.split(" "); + int spaceIndex; + + switch (parts[0]) { + case "bye": + System.out.println("Bye. Hope to see you again soon!"); + scanner.close(); + return; + + case "list": + for (int i = 0; i < count; i++) { + //example like 1.[T][X] read book + System.out.print((i + 1) + "."); + System.out.println(list[i]); + } + break; + + case "mark": + int taskNo = Integer.parseInt(parts[1]); //assume saved in part[1], need further improve + if( (taskNo > count ) || (taskNo <1) ){ + System.out.println("Oops! You don't have any task in this positions."); + } + else{ + list[taskNo].Done(); + System.out.println(" Nice! I've marked this task as done:\n" + + " [X] " + list[taskNo].description); + } + break; + + case "unmark": + int task = Integer.parseInt(parts[1]); //assume saved in part[1], need further improve + if( (task > count ) || (task <1) ){ + System.out.println("Oops! You don't have the task in this positions."); + } + else{ + list[count].unDone(); + System.out.println("OK, I've marked this task as not done yet:\n" + + " [ ] " + list[task].description); + } + break; + + case "todo": + // command e.g. todo borrow book + String[] todoSplit = command.split(" ", 2); + list[count] = new Todo(todoSplit[1]); + System.out.println("Got it. I've added this task:"); + System.out.println(list[count]); + count++; + System.out.println("Now you have " + count + " tasks in the list."); + break; + + case "deadline": + // command e.g. deadline return book /by Sunday + String[] ddlSplit = command.split("/"); + spaceIndex = ddlSplit[0].indexOf(" "); + String ddlTask = ddlSplit[0].substring(spaceIndex + 1).trim(); + list[count] = new Deadline(ddlTask, ddlSplit[1].substring(3)); + System.out.println("Got it. I've added this task:"); + System.out.println(list[count]); + count++; + System.out.println("Now you have " + count + " tasks in the list."); + break; + + case "event": + //command e.g. event project meeting /from Mon 2pm /to 4pm + String[] eventSplit = command.split("/"); + spaceIndex = eventSplit[0].indexOf(" "); + String eventTask = eventSplit[0].substring(spaceIndex + 1).trim(); + String start = eventSplit[1].trim().substring(5); // Remove "/from " prefix + String end = eventSplit[2].trim().substring(3); // Remove "/to " prefix + list[count] = new Event(eventTask, start, end); + System.out.println("Got it. I've added this task:"); + System.out.println(list[count]); + count++; + System.out.println("Now you have " + count + " tasks in the list."); + + default: + System.out.println("This is not expected. Do it again"); + } + } + + } } From d6f453712c6fe3c215f238cc151bee087677f262 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 7 Sep 2023 01:50:54 +0800 Subject: [PATCH 06/86] add new file "Event.java" as subclass of Task --- src/main/java/Event.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/Event.java b/src/main/java/Event.java index fe6147652..c3942b8e0 100644 --- a/src/main/java/Event.java +++ b/src/main/java/Event.java @@ -1,2 +1,17 @@ -package PACKAGE_NAME;public class Event { +public class Event extends Task { + protected String start, end; + + public Event(String description, String start, String end) { + super(description); + this.start = start; + this.end = end; + } + + + @Override + public String toString() { + //print example: [E][ ] project meeting (from: Aug 6th 2pm to: 4pm) + return "[E]" + super.toString() + " (from: " + this.start + " to: " + this.end + ")"; + } + } From 22f7501b1f3f14836a6f491900502aa43ffa5b96 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 7 Sep 2023 01:51:44 +0800 Subject: [PATCH 07/86] add new file "Task.java" as parent class of task objects --- src/main/java/Task.java | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/Task.java b/src/main/java/Task.java index 4ec445449..f9b02fbfb 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -1,2 +1,27 @@ -package PACKAGE_NAME;public class Task { +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 Done(){ + this.isDone = true; + } + + public void unDone(){ + this.isDone = false; + } + + @Override + public String toString() { + return "[" + this.getStatusIcon() + "] " + this.description; + } + } From a1515040e36340925b89924989e08ffc467540cc Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 7 Sep 2023 01:52:01 +0800 Subject: [PATCH 08/86] add new file "Todo.java" as subclass of Task --- src/main/java/Todo.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/Todo.java b/src/main/java/Todo.java index 73a10cb4d..fcff15c73 100644 --- a/src/main/java/Todo.java +++ b/src/main/java/Todo.java @@ -1,2 +1,11 @@ -package PACKAGE_NAME;public class Todo { +public class Todo extends Task { + + public Todo(String description) { + super(description); + } + + @Override + public String toString() { + return "[T]" + super.toString() ; + } } From 752b8bf56a3e65525ae2b69c780e2f917ed28778 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 7 Sep 2023 01:59:10 +0800 Subject: [PATCH 09/86] add file "EXPECTED.txt" to test the output. ***content not yet initialised --- src/main/java/text-ui-test/EXPECTED.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/java/text-ui-test/EXPECTED.txt diff --git a/src/main/java/text-ui-test/EXPECTED.txt b/src/main/java/text-ui-test/EXPECTED.txt new file mode 100644 index 000000000..e69de29bb From abd15480333559826dcd50e93c3a8f638c1d7a2b Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 7 Sep 2023 02:00:12 +0800 Subject: [PATCH 10/86] add "input.txt" containing the input commands --- src/main/java/text-ui-test/input.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/java/text-ui-test/input.txt diff --git a/src/main/java/text-ui-test/input.txt b/src/main/java/text-ui-test/input.txt new file mode 100644 index 000000000..e69de29bb From 677d91b0c696106b3a1745ef07633a6c3d04d951 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 7 Sep 2023 02:01:35 +0800 Subject: [PATCH 11/86] add "runtest.bat" to compile the file. ***main class location is not yet mateched --- src/main/java/text-ui-test/runtest.bat | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/text-ui-test/runtest.bat diff --git a/src/main/java/text-ui-test/runtest.bat b/src/main/java/text-ui-test/runtest.bat new file mode 100644 index 000000000..0b643f82e --- /dev/null +++ b/src/main/java/text-ui-test/runtest.bat @@ -0,0 +1,21 @@ +@ECHO OFF + +REM create bin directory if it doesn't exist +if not exist ..\bin mkdir ..\bin + +REM delete output from previous run +del ACTUAL.TXT + +REM compile the code into the bin folder +javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java +IF ERRORLEVEL 1 ( + echo ********** BUILD FAILURE ********** + exit /b 1 +) +REM no error here, errorlevel == 0 + +REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT +java -classpath ..\bin Duke < input.txt > ACTUAL.TXT + +REM compare the output to the expected output +FC ACTUAL.TXT EXPECTED.TXT \ No newline at end of file From 661743125f4b672ce725a6d0b5e8a8bf29fbf779 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sun, 10 Sep 2023 13:28:44 +0800 Subject: [PATCH 12/86] rename a few variables and methods to aviod confusion --- src/main/java/Deadline.java | 6 +-- src/main/java/Duke.java | 103 ++++++++++++++++++------------------ src/main/java/Task.java | 23 ++++++-- 3 files changed, 73 insertions(+), 59 deletions(-) diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java index e4e4b232c..24a31bff8 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/Deadline.java @@ -1,14 +1,14 @@ public class Deadline extends Task { - protected String by; + protected String byDeadline; public Deadline(String description, String by) { super(description); - this.by = by; + this.byDeadline = by; } @Override public String toString() { - return "[D]" + super.toString() + " (by: " + by + ")"; + return "[D]" + super.toString() + " (by: " + this.byDeadline + ")"; } } diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 333d58fad..e52d4d04b 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,65 +1,45 @@ import java.util.Scanner; public class Duke { - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - Task[] list = new Task[100]; - int count = 0; - System.out.println("Hello! I'm Oriento."); - System.out.println("What can I do for you?"); + public static int taskCount = 0; + private static Task[] list = new Task[100]; + + public static void main(String[] args) { + printWelcomeMessage(); + Scanner keyboard = new Scanner(System.in); while (true) { - String command = scanner.nextLine(); - String[] parts = command.split(" "); - int spaceIndex; + String command = keyboard.nextLine(); + String[] commendSplits = command.split(" "); + int spaceIndex, taskNo; - switch (parts[0]) { + switch (commendSplits[0]) { case "bye": - System.out.println("Bye. Hope to see you again soon!"); - scanner.close(); + printByeMessage(); + keyboard.close(); return; case "list": - for (int i = 0; i < count; i++) { - //example like 1.[T][X] read book - System.out.print((i + 1) + "."); - System.out.println(list[i]); - } + printList(taskCount, list); break; case "mark": - int taskNo = Integer.parseInt(parts[1]); //assume saved in part[1], need further improve - if( (taskNo > count ) || (taskNo <1) ){ - System.out.println("Oops! You don't have any task in this positions."); - } - else{ - list[taskNo].Done(); - System.out.println(" Nice! I've marked this task as done:\n" - + " [X] " + list[taskNo].description); - } + // command format e.g. mark 1 + taskNo = Integer.parseInt(commendSplits[1]); //assume saved in part[1], need further improve + list[taskNo - 1].setDone(taskNo, taskCount, list); break; case "unmark": - int task = Integer.parseInt(parts[1]); //assume saved in part[1], need further improve - if( (task > count ) || (task <1) ){ - System.out.println("Oops! You don't have the task in this positions."); - } - else{ - list[count].unDone(); - System.out.println("OK, I've marked this task as not done yet:\n" - + " [ ] " + list[task].description); - } + taskNo = Integer.parseInt(commendSplits[1]); //assume saved in part[1], need further improve + list[taskNo - 1].setNotDone(taskNo, taskCount, list); break; case "todo": - // command e.g. todo borrow book + // command format e.g. todo borrow book String[] todoSplit = command.split(" ", 2); - list[count] = new Todo(todoSplit[1]); - System.out.println("Got it. I've added this task:"); - System.out.println(list[count]); - count++; - System.out.println("Now you have " + count + " tasks in the list."); + list[taskCount] = new Todo(todoSplit[1]); + createTaskSuccessMsg(); break; case "deadline": @@ -67,11 +47,8 @@ public static void main(String[] args) { String[] ddlSplit = command.split("/"); spaceIndex = ddlSplit[0].indexOf(" "); String ddlTask = ddlSplit[0].substring(spaceIndex + 1).trim(); - list[count] = new Deadline(ddlTask, ddlSplit[1].substring(3)); - System.out.println("Got it. I've added this task:"); - System.out.println(list[count]); - count++; - System.out.println("Now you have " + count + " tasks in the list."); + list[taskCount] = new Deadline(ddlTask, ddlSplit[1].substring(3)); + createTaskSuccessMsg(); break; case "event": @@ -81,17 +58,39 @@ public static void main(String[] args) { String eventTask = eventSplit[0].substring(spaceIndex + 1).trim(); String start = eventSplit[1].trim().substring(5); // Remove "/from " prefix String end = eventSplit[2].trim().substring(3); // Remove "/to " prefix - list[count] = new Event(eventTask, start, end); - System.out.println("Got it. I've added this task:"); - System.out.println(list[count]); - count++; - System.out.println("Now you have " + count + " tasks in the list."); + list[taskCount] = new Event(eventTask, start, end); + createTaskSuccessMsg(); + break; default: - System.out.println("This is not expected. Do it again"); + System.out.println("Sorry. This is not expected."); + System.out.println("Please type in \"help\" to look for command format"); } } + } + + private static void createTaskSuccessMsg() { + System.out.println("Got it. I've added this task:"); + System.out.println(list[taskCount]); + taskCount++; + System.out.println("Now you have " + taskCount + " tasks in the list."); + } + private static void printByeMessage() { + System.out.println("Bye. Hope to see you again soon!"); } + + private static void printWelcomeMessage() { + System.out.println("Hello! I'm Oriento."); + System.out.println("What can I do for you?"); + } + + private static void printList(int count, Task[] list) { + for (int i = 0; i < count; i++) { + //example 1.[T][X] read book + System.out.println((i + 1) + "." + list[i]); + } + } + } diff --git a/src/main/java/Task.java b/src/main/java/Task.java index f9b02fbfb..e1b2f2e99 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -11,12 +11,27 @@ public String getStatusIcon() { return (isDone ? "X" : " "); // mark done task with X } - public void Done(){ - this.isDone = true; + public void setDone(int taskNo, int taskCount, Task[] list){ + if( (taskNo > taskCount ) || (taskNo <1) ){ + System.out.println("Oops! You don't have any task in this positions."); + } + else{ + this.isDone = true; + System.out.println(" Nice! I've marked this task as done:\n" + + " [X] " + list[taskNo - 1].description); + } } - public void unDone(){ - this.isDone = false; + public void setNotDone(int taskNo, int taskCount, Task[] list){ + if( (taskNo > taskCount ) || (taskNo <1) ){ + System.out.println("Oops! You don't have any task in this position."); + }else if(!this.isDone){ + System.out.println("Oh, you haven't finished this yet."); + } else{ + this.isDone = false; + System.out.println("OK, I've marked this task as not done yet:\n" + + " [ ] " + list[taskNo - 1].description); + } } @Override From 0c932c02440a4b1d47e6b22886566a0c4daa7cd2 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sun, 10 Sep 2023 13:36:23 +0800 Subject: [PATCH 13/86] create more methods to different classes by code extraction to become OO style --- src/main/java/Task.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/Task.java b/src/main/java/Task.java index e1b2f2e99..6d8b811ce 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -14,8 +14,9 @@ public String getStatusIcon() { public void setDone(int taskNo, int taskCount, Task[] list){ if( (taskNo > taskCount ) || (taskNo <1) ){ System.out.println("Oops! You don't have any task in this positions."); - } - else{ + }else if(this.isDone){ + System.out.println("You have already completed the task."); + } else{ this.isDone = true; System.out.println(" Nice! I've marked this task as done:\n" + " [X] " + list[taskNo - 1].description); From 4024b7ff3895e0a38358b158d495531eea5a35e1 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sun, 10 Sep 2023 13:37:21 +0800 Subject: [PATCH 14/86] initialise the content of input and expected output txt to conduct a simple output run --- src/main/java/text-ui-test/EXPECTED.txt | 22 ++++++++++++++++++++++ src/main/java/text-ui-test/input.txt | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/src/main/java/text-ui-test/EXPECTED.txt b/src/main/java/text-ui-test/EXPECTED.txt index e69de29bb..2a13a1132 100644 --- a/src/main/java/text-ui-test/EXPECTED.txt +++ b/src/main/java/text-ui-test/EXPECTED.txt @@ -0,0 +1,22 @@ +Hello! I'm Oriento. +What can I do for you? +Got it. I've added this task: +[T][ ] read book +Now you have 1 tasks in the list. +Got it. I've added this task: +[T][ ] play piano +Now you have 2 tasks in the list. + Nice! I've marked this task as done: + [X] play piano +Got it. I've added this task: +[D][ ] return book (by: Friday) +Now you have 3 tasks in the list. +Got it. I've added this task: +[E][ ] java lesson (from: Friday 4pm to: 6pm) +Now you have 4 tasks in the list. +Oh, you haven't finished this yet. +1.[T][ ] read book +2.[T][X] play piano +3.[D][ ] return book (by: Friday) +4.[E][ ] java lesson (from: Friday 4pm to: 6pm) +Bye. Hope to see you again soon! diff --git a/src/main/java/text-ui-test/input.txt b/src/main/java/text-ui-test/input.txt index e69de29bb..eb726634e 100644 --- a/src/main/java/text-ui-test/input.txt +++ b/src/main/java/text-ui-test/input.txt @@ -0,0 +1,8 @@ +todo read book +todo play piano +mark 2 +deadline return book /by Friday +event java lesson /from Friday 4pm /to 6pm +unmark 4 +list +bye From e01ca3e923b7c323e5063702ba6881576f0daa86 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 15 Sep 2023 10:11:38 +0800 Subject: [PATCH 15/86] - add task object creation methods for all kind of task to improve readability of the main(Duke) class - ready to trackle exception --- src/main/java/Deadline.java | 17 +++++++++++++---- src/main/java/Duke.java | 28 ++++++++++++++-------------- src/main/java/Event.java | 10 ++++++++++ src/main/java/Task.java | 12 ++++++------ src/main/java/Todo.java | 7 +++++++ 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java index 24a31bff8..f3aa24338 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/Deadline.java @@ -1,14 +1,23 @@ public class Deadline extends Task { - protected String byDeadline; + protected String due; - public Deadline(String description, String by) { + public Deadline(String description, String due) { super(description); - this.byDeadline = by; + this.due = due; + } + + public static Deadline newDdl(String userCommand) { + // command format: deadline return book /by Sunday + String[] ddlSplit = userCommand.split("/"); + int spaceIndex = ddlSplit[0].indexOf(" "); + String ddlTask = ddlSplit[0].substring(spaceIndex + 1).trim(); + + return new Deadline(ddlTask, ddlSplit[1].substring(3)); } @Override public String toString() { - return "[D]" + super.toString() + " (by: " + this.byDeadline + ")"; + return "[D]" + super.toString() + " (by: " + this.due + ")"; } } diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index e52d4d04b..7f8c8f4a0 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -15,50 +15,48 @@ public static void main(String[] args) { int spaceIndex, taskNo; switch (commendSplits[0]) { + case "Bye": case "bye": printByeMessage(); keyboard.close(); return; + case "List": case "list": printList(taskCount, list); break; + case "Mark": case "mark": // command format e.g. mark 1 - taskNo = Integer.parseInt(commendSplits[1]); //assume saved in part[1], need further improve + taskNo = Integer.parseInt(commendSplits[1]); list[taskNo - 1].setDone(taskNo, taskCount, list); break; + case "Unmark": case "unmark": - taskNo = Integer.parseInt(commendSplits[1]); //assume saved in part[1], need further improve + taskNo = Integer.parseInt(commendSplits[1]); list[taskNo - 1].setNotDone(taskNo, taskCount, list); break; + case "Todo": case "todo": // command format e.g. todo borrow book - String[] todoSplit = command.split(" ", 2); - list[taskCount] = new Todo(todoSplit[1]); + list[taskCount] = Todo.newTodoTask(command); createTaskSuccessMsg(); break; + case "Deadline": case "deadline": // command e.g. deadline return book /by Sunday - String[] ddlSplit = command.split("/"); - spaceIndex = ddlSplit[0].indexOf(" "); - String ddlTask = ddlSplit[0].substring(spaceIndex + 1).trim(); - list[taskCount] = new Deadline(ddlTask, ddlSplit[1].substring(3)); + list[taskCount] = Deadline.newDdl(command); createTaskSuccessMsg(); break; + case "Event": case "event": //command e.g. event project meeting /from Mon 2pm /to 4pm - String[] eventSplit = command.split("/"); - spaceIndex = eventSplit[0].indexOf(" "); - String eventTask = eventSplit[0].substring(spaceIndex + 1).trim(); - String start = eventSplit[1].trim().substring(5); // Remove "/from " prefix - String end = eventSplit[2].trim().substring(3); // Remove "/to " prefix - list[taskCount] = new Event(eventTask, start, end); + list[taskCount] = Event.newEventTask(command); createTaskSuccessMsg(); break; @@ -93,4 +91,6 @@ private static void printList(int count, Task[] list) { } } + + } diff --git a/src/main/java/Event.java b/src/main/java/Event.java index c3942b8e0..f9a1c0227 100644 --- a/src/main/java/Event.java +++ b/src/main/java/Event.java @@ -7,6 +7,16 @@ public Event(String description, String start, String end) { this.end = end; } + public static Event newEventTask(String userCommand) { + //command format: event project meeting /from Mon 2pm /to 4pm + String[] eventSplit = userCommand.split("/"); + int spaceIndex = eventSplit[0].indexOf(" "); + String eventTask = eventSplit[0].substring(spaceIndex + 1).trim(); + String start = eventSplit[1].trim().substring(5); // Remove "/from " prefix + String end = eventSplit[2].trim().substring(3); // Remove "/to " prefix + return new Event(eventTask, start, end); + } + @Override public String toString() { diff --git a/src/main/java/Task.java b/src/main/java/Task.java index 6d8b811ce..e67f1500c 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -11,10 +11,10 @@ public String getStatusIcon() { return (isDone ? "X" : " "); // mark done task with X } - public void setDone(int taskNo, int taskCount, Task[] list){ - if( (taskNo > taskCount ) || (taskNo <1) ){ + public void setDone(int taskNo, int taskCount, Task[] list) { + if ( (taskNo > taskCount ) || (taskNo <1) ){ System.out.println("Oops! You don't have any task in this positions."); - }else if(this.isDone){ + } else if(this.isDone){ System.out.println("You have already completed the task."); } else{ this.isDone = true; @@ -23,10 +23,10 @@ public void setDone(int taskNo, int taskCount, Task[] list){ } } - public void setNotDone(int taskNo, int taskCount, Task[] list){ - if( (taskNo > taskCount ) || (taskNo <1) ){ + public void setNotDone(int taskNo, int taskCount, Task[] list) { + if ( (taskNo > taskCount ) || (taskNo <1) ){ System.out.println("Oops! You don't have any task in this position."); - }else if(!this.isDone){ + } else if(!this.isDone){ System.out.println("Oh, you haven't finished this yet."); } else{ this.isDone = false; diff --git a/src/main/java/Todo.java b/src/main/java/Todo.java index fcff15c73..b7b777539 100644 --- a/src/main/java/Todo.java +++ b/src/main/java/Todo.java @@ -4,6 +4,13 @@ public Todo(String description) { super(description); } + + public static Todo newTodoTask(String userCommand) { + String[] todoSplit = userCommand.split(" ", 2); + return new Todo(todoSplit[1]); + } + + @Override public String toString() { return "[T]" + super.toString() ; From 888d9c5e3e80ecbe9a01cfc22639c72d872acaa3 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 15 Sep 2023 10:12:59 +0800 Subject: [PATCH 16/86] remove unused variable spaceIndex --- src/main/java/Duke.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 7f8c8f4a0..c82e36562 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -12,7 +12,7 @@ public static void main(String[] args) { while (true) { String command = keyboard.nextLine(); String[] commendSplits = command.split(" "); - int spaceIndex, taskNo; + int taskNo; switch (commendSplits[0]) { case "Bye": From ec736b8f8340c14a13aa89b2aa33990b6c3c3218 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 15 Sep 2023 21:34:31 +0800 Subject: [PATCH 17/86] - Implement exception to catch some main error caused by user inputs - Seperate files into different package for easier management --- src/main/java/Duke.java | 96 ------------ src/main/java/duke/Duke.java | 143 ++++++++++++++++++ src/main/java/exception/DukeException.java | 45 ++++++ src/main/java/{ => task}/Deadline.java | 10 +- src/main/java/{ => task}/Event.java | 9 +- src/main/java/{ => task}/Task.java | 4 + src/main/java/{ => task}/Todo.java | 10 +- src/text-ui-test/ACTUAL.TXT | 0 src/{main/java => }/text-ui-test/EXPECTED.txt | 0 src/{main/java => }/text-ui-test/input.txt | 0 src/{main/java => }/text-ui-test/runtest.bat | 0 text-ui-test/runtest.bat | 4 +- 12 files changed, 219 insertions(+), 102 deletions(-) delete mode 100644 src/main/java/Duke.java create mode 100644 src/main/java/duke/Duke.java create mode 100644 src/main/java/exception/DukeException.java rename src/main/java/{ => task}/Deadline.java (69%) rename src/main/java/{ => task}/Event.java (75%) rename src/main/java/{ => task}/Task.java (96%) rename src/main/java/{ => task}/Todo.java (54%) create mode 100644 src/text-ui-test/ACTUAL.TXT rename src/{main/java => }/text-ui-test/EXPECTED.txt (100%) rename src/{main/java => }/text-ui-test/input.txt (100%) rename src/{main/java => }/text-ui-test/runtest.bat (100%) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java deleted file mode 100644 index c82e36562..000000000 --- a/src/main/java/Duke.java +++ /dev/null @@ -1,96 +0,0 @@ -import java.util.Scanner; - -public class Duke { - - public static int taskCount = 0; - private static Task[] list = new Task[100]; - - public static void main(String[] args) { - printWelcomeMessage(); - Scanner keyboard = new Scanner(System.in); - - while (true) { - String command = keyboard.nextLine(); - String[] commendSplits = command.split(" "); - int taskNo; - - switch (commendSplits[0]) { - case "Bye": - case "bye": - printByeMessage(); - keyboard.close(); - return; - - case "List": - case "list": - printList(taskCount, list); - break; - - case "Mark": - case "mark": - // command format e.g. mark 1 - taskNo = Integer.parseInt(commendSplits[1]); - list[taskNo - 1].setDone(taskNo, taskCount, list); - break; - - case "Unmark": - case "unmark": - taskNo = Integer.parseInt(commendSplits[1]); - list[taskNo - 1].setNotDone(taskNo, taskCount, list); - break; - - case "Todo": - case "todo": - // command format e.g. todo borrow book - list[taskCount] = Todo.newTodoTask(command); - createTaskSuccessMsg(); - break; - - case "Deadline": - case "deadline": - // command e.g. deadline return book /by Sunday - list[taskCount] = Deadline.newDdl(command); - createTaskSuccessMsg(); - break; - - case "Event": - case "event": - //command e.g. event project meeting /from Mon 2pm /to 4pm - list[taskCount] = Event.newEventTask(command); - createTaskSuccessMsg(); - break; - - default: - System.out.println("Sorry. This is not expected."); - System.out.println("Please type in \"help\" to look for command format"); - } - } - - } - - private static void createTaskSuccessMsg() { - System.out.println("Got it. I've added this task:"); - System.out.println(list[taskCount]); - taskCount++; - System.out.println("Now you have " + taskCount + " tasks in the list."); - } - - private static void printByeMessage() { - System.out.println("Bye. Hope to see you again soon!"); - } - - private static void printWelcomeMessage() { - System.out.println("Hello! I'm Oriento."); - System.out.println("What can I do for you?"); - } - - private static void printList(int count, Task[] list) { - for (int i = 0; i < count; i++) { - //example 1.[T][X] read book - System.out.println((i + 1) + "." + list[i]); - } - } - - - -} diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java new file mode 100644 index 000000000..cce25adab --- /dev/null +++ b/src/main/java/duke/Duke.java @@ -0,0 +1,143 @@ +package duke; + +import task.Event; +import task.Task; +import task.Deadline; +import task.Todo; + +import exception.DukeException; + +import java.util.Scanner; + +public class Duke { + + public static int taskCount = 0; + private static Task[] list = new Task[100]; + + public static void main(String[] args) throws DukeException { + printWelcomeMessage(); + Scanner keyboard = new Scanner(System.in); + + while (true) { + int taskNo; + String command = keyboard.nextLine().trim().toLowerCase(); //small letter and remove front and back space + String[] commendSplits = command.split(" "); + if (missingOrExtraTaskDescription(commendSplits)){ + continue; + } + + try { + switch (commendSplits[0]) { + case "bye": + printByeMessage(); + keyboard.close(); + return; + + case "list": + printList(taskCount, list); + break; + + case "mark": + // command format e.g. mark 1 + taskNo = getTaskNo(commendSplits[1]); + list[taskNo - 1].setDone(taskNo, taskCount, list); + break; + + case "unmark": + taskNo = getTaskNo(commendSplits[1]); + list[taskNo - 1].setNotDone(taskNo, taskCount, list); + break; + + case "todo": + // command format e.g. todo borrow book + list[taskCount] = Todo.newTodoTask(command); + createTaskSuccessMsg(); + break; + + case "deadline": + // command e.g. deadline return book /by Sunday + list[taskCount] = Deadline.newDdl(command); + createTaskSuccessMsg(); + break; + + case "event": + //command e.g. event project meeting /from Mon 2pm /to 4pm + list[taskCount] = Event.newEventTask(command); + createTaskSuccessMsg(); + break; + + default: + throw new DukeException(); + } + } catch (NumberFormatException nfe) { + System.out.println("Hey, please input your command with the correct task number."); + } catch (NullPointerException npe){ + System.out.println("Your target task doesn't exist. Please input a correct task."); + } catch (DukeException e){ + e.incorrectFormatException(commendSplits[0]); + } + } + + } + + private static int getTaskNo(String taskNum){ + //exception: taskNum is not number, or containing non-numerical value + return Integer.parseInt(taskNum); + } + + //To tackle cases of invalid input like 'todo', 'event', etc. + private static boolean missingOrExtraTaskDescription(String[] cmd){ + if (cmd.length == 1){ + if(cmd[0].equals("todo") || cmd[0].equals("event") || cmd[0].equals("deadline") + || cmd[0].equals("mark") || cmd[0].equals("unmark") ){ + System.out.println("Please describe your target."); + return true; + } + } + else if (cmd.length>=2 && cmd[0].equals("list")){ + System.out.println("Do you mean to see the list? Please try again using 'list'."); + return true; + } + return false; + } + + private static void createTaskSuccessMsg() { + System.out.println("Got it. I've added this task:"); + System.out.println(list[taskCount]); + taskCount++; + System.out.println("Now you have " + taskCount + " tasks in the list."); + } + + private static void printByeMessage() { + System.out.println("Bye. Hope to see you again soon!"); + } + + private static void printWelcomeMessage() { + System.out.println("Hello! I'm Oriento."); + System.out.println("What can I help you?"); + System.out.println("⣿⣿⣿⠟⠛⠛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢋⣩⣉⢻⣿\n" + + "⣿⣿⣿⠀⣿⣶⣕⣈⠹⠿⠿⠿⠿⠟⠛⣛⢋⣰⠣⣿⣿⠀⣿⣿\n" + + "⣿⣿⣿⡀⣿⣿⣿⣧⢻⣿⣶⣷⣿⣿⣿⣿⣿⣿⠿⠶⡝⠀⣿⣿\n" + + "⣿⣿⣿⣷⠘⣿⣿⣿⢏⣿⣿⣋⣀⣈⣻⣿⣿⣷⣤⣤⣿⡐⢿⣿\n" + + "⣿⣿⣿⣿⣆⢩⣝⣫⣾⣿⣿⣿⣿⡟⠿⠿⠦⠀⠸⠿⣻⣿⡄⢻⣿\n" + + "⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⠇⣼⣿\n" + + "⣿⣿⣿⣿⣿⣿⡄⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣰⣿\n" + + "⣿⣿⣿⣿⣿⣿⠇⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣿⣿\n" + + "⣿⣿⣿⣿⣿⠏⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢸⣿⣿\n" + + "⣿⣿⣿⣿⠟⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⣿⣿\n" + + "⣿⣿⣿⠋⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⣿⣿\n" + + "⣿⣿⠋⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿\n"); + } + + private static void printList(int count, Task[] list) { + if (taskCount == 0){ + System.out.println("You don't have any tasks now. Do you want to add a new task?"); + return; + } + for (int i = 0; i < count; i++) { + //example 1.[T][X] read book + System.out.println((i + 1) + "." + list[i]); + } + } + +} diff --git a/src/main/java/exception/DukeException.java b/src/main/java/exception/DukeException.java new file mode 100644 index 000000000..fc0b43efd --- /dev/null +++ b/src/main/java/exception/DukeException.java @@ -0,0 +1,45 @@ +package exception; + +public class DukeException extends Exception { + + public DukeException() { + } + + public DukeException(String message) { + super(message); + } + + private void sendIncorrectMsg(String taskType){ + System.out.println("Sorry, your command for " + taskType + " task is not in the correct format. Please try again."); + } + + public void incorrectFormatException(String taskType) { + switch (taskType){ + case "todo": + sendIncorrectMsg("todo"); + System.out.println("Correct format: todo 'Your Todo Task' "); + System.out.println("Example: todo read book"); + break; + + case "deadline": + sendIncorrectMsg("deadline"); + System.out.println("Correct format: deadline 'Your Deadline Task' /by 'Due Time' "); + System.out.println("Example: deadline return book /by Sunday 6pm"); + break; + + case "event": + sendIncorrectMsg("event"); + System.out.println("Correct format: event 'Your Event Task' /from 'Starting Time' /to 'End Time' "); + System.out.println("Example: event project meeting /from Mon 2pm /to 4pm"); + break; + + default: + //for case without correct start and empty command + System.out.println("Please start with the supported task types: 'todo', 'deadline', 'event'. "); + } + + + + } +} + diff --git a/src/main/java/Deadline.java b/src/main/java/task/Deadline.java similarity index 69% rename from src/main/java/Deadline.java rename to src/main/java/task/Deadline.java index f3aa24338..50e8b72f1 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/task/Deadline.java @@ -1,3 +1,7 @@ +package task; + +import exception.DukeException; + public class Deadline extends Task { protected String due; @@ -7,8 +11,12 @@ public Deadline(String description, String due) { this.due = due; } - public static Deadline newDdl(String userCommand) { + public static Deadline newDdl(String userCommand) throws DukeException { // command format: deadline return book /by Sunday + if (!(userCommand.contains("/by"))){ + throw new DukeException("Oh, no! I cannot detect the keyword '/by' "); + } + String[] ddlSplit = userCommand.split("/"); int spaceIndex = ddlSplit[0].indexOf(" "); String ddlTask = ddlSplit[0].substring(spaceIndex + 1).trim(); diff --git a/src/main/java/Event.java b/src/main/java/task/Event.java similarity index 75% rename from src/main/java/Event.java rename to src/main/java/task/Event.java index f9a1c0227..68fb2e4bf 100644 --- a/src/main/java/Event.java +++ b/src/main/java/task/Event.java @@ -1,3 +1,7 @@ +package task; + +import exception.DukeException; + public class Event extends Task { protected String start, end; @@ -7,8 +11,11 @@ public Event(String description, String start, String end) { this.end = end; } - public static Event newEventTask(String userCommand) { + public static Event newEventTask(String userCommand) throws DukeException { //command format: event project meeting /from Mon 2pm /to 4pm + if (!(userCommand.contains("/from")) || !(userCommand.contains("/to"))){ + throw new DukeException("Oh, no! There is no '/from' or '/to' "); + } String[] eventSplit = userCommand.split("/"); int spaceIndex = eventSplit[0].indexOf(" "); String eventTask = eventSplit[0].substring(spaceIndex + 1).trim(); diff --git a/src/main/java/Task.java b/src/main/java/task/Task.java similarity index 96% rename from src/main/java/Task.java rename to src/main/java/task/Task.java index e67f1500c..9c8f5c5fe 100644 --- a/src/main/java/Task.java +++ b/src/main/java/task/Task.java @@ -1,3 +1,7 @@ +package task; + +import exception.DukeException; + public class Task { protected String description; protected boolean isDone; diff --git a/src/main/java/Todo.java b/src/main/java/task/Todo.java similarity index 54% rename from src/main/java/Todo.java rename to src/main/java/task/Todo.java index b7b777539..4aad0841d 100644 --- a/src/main/java/Todo.java +++ b/src/main/java/task/Todo.java @@ -1,12 +1,18 @@ +package task; + +import exception.DukeException; + public class Todo extends Task { public Todo(String description) { super(description); } - - public static Todo newTodoTask(String userCommand) { + public static Todo newTodoTask(String userCommand) throws DukeException { String[] todoSplit = userCommand.split(" ", 2); + if ( todoSplit[1].isEmpty() ){ + throw new DukeException("You got nothing to create. Please try again."); + } return new Todo(todoSplit[1]); } diff --git a/src/text-ui-test/ACTUAL.TXT b/src/text-ui-test/ACTUAL.TXT new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/java/text-ui-test/EXPECTED.txt b/src/text-ui-test/EXPECTED.txt similarity index 100% rename from src/main/java/text-ui-test/EXPECTED.txt rename to src/text-ui-test/EXPECTED.txt diff --git a/src/main/java/text-ui-test/input.txt b/src/text-ui-test/input.txt similarity index 100% rename from src/main/java/text-ui-test/input.txt rename to src/text-ui-test/input.txt diff --git a/src/main/java/text-ui-test/runtest.bat b/src/text-ui-test/runtest.bat similarity index 100% rename from src/main/java/text-ui-test/runtest.bat rename to src/text-ui-test/runtest.bat diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat index 087374464..a230843b0 100644 --- a/text-ui-test/runtest.bat +++ b/text-ui-test/runtest.bat @@ -7,7 +7,7 @@ REM delete output from previous run if exist ACTUAL.TXT del ACTUAL.TXT REM compile the code into the bin folder -javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java +javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\duke\*.java ..\src\main\java\exception\*.java ..\src\main\java\task\*.java IF ERRORLEVEL 1 ( echo ********** BUILD FAILURE ********** exit /b 1 @@ -15,7 +15,7 @@ IF ERRORLEVEL 1 ( REM no error here, errorlevel == 0 REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT -java -classpath ..\bin Duke < input.txt > ACTUAL.TXT +java -classpath ..\bin duke.Duke < input.txt > ACTUAL.TXT REM compare the output to the expected output FC ACTUAL.TXT EXPECTED.TXT From f87152bd489b340ebec55916aeee35286a10886d Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sat, 16 Sep 2023 02:37:31 +0800 Subject: [PATCH 18/86] add the delete method and some exception handling for the method --- src/main/java/duke/Duke.java | 29 ++++++++++++++++++++-- src/main/java/exception/DukeException.java | 3 +++ src/main/java/task/Task.java | 12 +++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index cce25adab..5e0829835 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -1,5 +1,5 @@ package duke; - +// ASS1, ASS2 INPUT, REMOVE 1, PRINT TO HAVE 1.... import task.Event; import task.Task; import task.Deadline; @@ -48,6 +48,11 @@ public static void main(String[] args) throws DukeException { list[taskNo - 1].setNotDone(taskNo, taskCount, list); break; + case "delete": + taskNo = getTaskNo(commendSplits[1]); + deleteTask(taskNo); + break; + case "todo": // command format e.g. todo borrow book list[taskCount] = Todo.newTodoTask(command); @@ -85,11 +90,24 @@ private static int getTaskNo(String taskNum){ return Integer.parseInt(taskNum); } + public static Task[] getTaskList() { + return list; + } + + private static void deleteTask(int deleteIndex) { + if (deleteIndex <= 0 || deleteIndex> Duke.taskCount){ + System.out.println("Oh, No! invalid index! You don't have that task. Please try again."); + return; + } + deleteTaskSuccessMsg(deleteIndex); + list = Task.updatedTaskList(deleteIndex - 1); + } + //To tackle cases of invalid input like 'todo', 'event', etc. private static boolean missingOrExtraTaskDescription(String[] cmd){ if (cmd.length == 1){ if(cmd[0].equals("todo") || cmd[0].equals("event") || cmd[0].equals("deadline") - || cmd[0].equals("mark") || cmd[0].equals("unmark") ){ + || cmd[0].equals("mark") || cmd[0].equals("unmark") || cmd[0].equals("delete")){ System.out.println("Please describe your target."); return true; } @@ -108,6 +126,13 @@ private static void createTaskSuccessMsg() { System.out.println("Now you have " + taskCount + " tasks in the list."); } + private static void deleteTaskSuccessMsg(int deleteIndex) { + System.out.println("Noted. I've removed this task:"); + System.out.println(list[deleteIndex - 1]); + taskCount--; + System.out.println("Now you have " + taskCount + " tasks in the list."); + } + private static void printByeMessage() { System.out.println("Bye. Hope to see you again soon!"); } diff --git a/src/main/java/exception/DukeException.java b/src/main/java/exception/DukeException.java index fc0b43efd..9f3bd1b40 100644 --- a/src/main/java/exception/DukeException.java +++ b/src/main/java/exception/DukeException.java @@ -33,6 +33,9 @@ public void incorrectFormatException(String taskType) { System.out.println("Example: event project meeting /from Mon 2pm /to 4pm"); break; + case "delete": + break; + default: //for case without correct start and empty command System.out.println("Please start with the supported task types: 'todo', 'deadline', 'event'. "); diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java index 9c8f5c5fe..d3f312bf6 100644 --- a/src/main/java/task/Task.java +++ b/src/main/java/task/Task.java @@ -1,7 +1,10 @@ package task; +import duke.Duke; import exception.DukeException; +import java.util.Arrays; + public class Task { protected String description; protected boolean isDone; @@ -39,6 +42,15 @@ public void setNotDone(int taskNo, int taskCount, Task[] list) { } } + //return a new list after delete the target object + public static Task[] updatedTaskList(int indexOfDelete){ + Task[] newList = new Task[100]; + int numOfCopy = Duke.getTaskList().length - indexOfDelete - 1; + System.arraycopy(Duke.getTaskList(), 0, newList, 0, indexOfDelete); + System.arraycopy(Duke.getTaskList(), indexOfDelete + 1, newList, indexOfDelete, numOfCopy); + return newList; + } + @Override public String toString() { return "[" + this.getStatusIcon() + "] " + this.description; From eabd967b31e8eac40fd6d6adbcbf6c5f8ef44f7f Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 21 Sep 2023 23:03:13 +0800 Subject: [PATCH 19/86] -implement file input ouput methods to sava the tasks data -add file and data checker methods if files or folder not exist, create one; if failed to create, throw error for incorrect path -add backup method to save all currect data in current run of program -correct bugs on fileIO over creating new task or delete task --- src/main/java/duke/Duke.java | 112 ++++++++++++++++++++++++++++++++--- src/main/java/task/Task.java | 2 - 2 files changed, 103 insertions(+), 11 deletions(-) diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 5e0829835..6bee17c8d 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -1,12 +1,22 @@ package duke; -// ASS1, ASS2 INPUT, REMOVE 1, PRINT TO HAVE 1.... + + import task.Event; import task.Task; import task.Deadline; import task.Todo; import exception.DukeException; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.File; +import java.io.FileWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.nio.file.StandardCopyOption; import java.util.Scanner; public class Duke { @@ -14,9 +24,12 @@ public class Duke { public static int taskCount = 0; private static Task[] list = new Task[100]; - public static void main(String[] args) throws DukeException { + public static void main(String[] args) throws IOException{ printWelcomeMessage(); Scanner keyboard = new Scanner(System.in); + checkAndCreateDataFolder(); + checkAndCreateFile("data\\taskList.txt"); + clearData(); while (true) { int taskNo; @@ -34,7 +47,7 @@ public static void main(String[] args) throws DukeException { return; case "list": - printList(taskCount, list); + printList(); break; case "mark": @@ -71,6 +84,10 @@ public static void main(String[] args) throws DukeException { createTaskSuccessMsg(); break; + case "save": + backupTaskFile(); + break; + default: throw new DukeException(); } @@ -80,12 +97,16 @@ public static void main(String[] args) throws DukeException { System.out.println("Your target task doesn't exist. Please input a correct task."); } catch (DukeException e){ e.incorrectFormatException(commendSplits[0]); + } catch (FileNotFoundException fnf){ + System.out.println("Sorry, I cannot find the task source. Please check the task file."); + } catch (IOException io){ + System.out.println("OMG! Something went wrong! Please check if the source files are available."); } } } - private static int getTaskNo(String taskNum){ + private static int getTaskNo(String taskNum) { //exception: taskNum is not number, or containing non-numerical value return Integer.parseInt(taskNum); } @@ -94,13 +115,24 @@ public static Task[] getTaskList() { return list; } - private static void deleteTask(int deleteIndex) { + private static void deleteTask(int deleteIndex) throws IOException{ if (deleteIndex <= 0 || deleteIndex> Duke.taskCount){ System.out.println("Oh, No! invalid index! You don't have that task. Please try again."); return; } deleteTaskSuccessMsg(deleteIndex); list = Task.updatedTaskList(deleteIndex - 1); + overwriteToFile("data/taskList.txt", getConcatenateTasks()); + } + + //This method will return all tasks inside the list + private static String getConcatenateTasks() { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < taskCount; i++) { + String taskAppend = (i +1) + ". " + list[i].toString(); + stringBuilder.append(taskAppend).append("\n"); + } + return stringBuilder.toString(); } //To tackle cases of invalid input like 'todo', 'event', etc. @@ -112,18 +144,24 @@ private static boolean missingOrExtraTaskDescription(String[] cmd){ return true; } } - else if (cmd.length>=2 && cmd[0].equals("list")){ + else if (cmd.length>=2 && cmd[0].equals("list") ){ System.out.println("Do you mean to see the list? Please try again using 'list'."); return true; + }else if (cmd.length>=2 && cmd[0].equals("save") ){ + System.out.println("Do you mean to save the tasks? Please try again using 'save'."); + return true; } return false; } - private static void createTaskSuccessMsg() { + private static void createTaskSuccessMsg() throws IOException{ System.out.println("Got it. I've added this task:"); System.out.println(list[taskCount]); taskCount++; System.out.println("Now you have " + taskCount + " tasks in the list."); + + String taskAppend = taskCount + ". " + list[taskCount - 1].toString() + "\n"; + writeToFile("data/taskList.txt", taskAppend); } private static void deleteTaskSuccessMsg(int deleteIndex) { @@ -133,10 +171,23 @@ private static void deleteTaskSuccessMsg(int deleteIndex) { System.out.println("Now you have " + taskCount + " tasks in the list."); } - private static void printByeMessage() { + + private static void printByeMessage(){ System.out.println("Bye. Hope to see you again soon!"); } + private static void clearData() throws IOException { + Path clearFile = Paths.get("data/taskList.txt"); + Files.write(clearFile, new byte[0], StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); + } + + private static void backupTaskFile() throws IOException{ + Path sourcePath = Paths.get("data/taskList.txt"); + Path targetPath = Paths.get("data/backup_taskList.txt"); + Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); //if file not exist, create one; + System.out.println("Great! I have saved the current tasks."); + } + private static void printWelcomeMessage() { System.out.println("Hello! I'm Oriento."); System.out.println("What can I help you?"); @@ -154,14 +205,57 @@ private static void printWelcomeMessage() { "⣿⣿⠋⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿\n"); } - private static void printList(int count, Task[] list) { + private static void printList() throws IOException{ if (taskCount == 0){ System.out.println("You don't have any tasks now. Do you want to add a new task?"); return; } + printFileContents("data/taskList.txt"); + + // This is to print the whole task message directly + /* for (int i = 0; i < count; i++) { //example 1.[T][X] read book System.out.println((i + 1) + "." + list[i]); + }*/ + + } + + private static void printFileContents(String filePath) throws IOException { + File f = new File(filePath); // create a File for the given file path + Scanner s = new Scanner(f); // create a Scanner using the File as the source + while (s.hasNext()) { + System.out.println(s.nextLine()); + } + } + + private static void writeToFile(String filePath, String taskAppend) throws IOException { + FileWriter fw = new FileWriter(filePath, true); + fw.write(taskAppend); + fw.close(); + } + + private static void overwriteToFile(String filePath, String taskAppend) throws IOException { + FileWriter fw = new FileWriter(filePath); + fw.write(taskAppend); + fw.close(); + } + + public static void checkAndCreateFile(String path) throws IOException { + File f = new File(path); + if(!f.exists()){ + if(!f.createNewFile()){ + throw new IOException(); + } + } + } + + public static void checkAndCreateDataFolder() throws IOException { + File folder = new File("data"); + if (!folder.isDirectory()) { + if(!folder.mkdirs()){ + throw new IOException(); + } } } diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java index d3f312bf6..529604a93 100644 --- a/src/main/java/task/Task.java +++ b/src/main/java/task/Task.java @@ -1,9 +1,7 @@ package task; import duke.Duke; -import exception.DukeException; -import java.util.Arrays; public class Task { protected String description; From 73d471465132e1d219e5097d4a59113756bfa8fa Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Thu, 21 Sep 2023 23:04:24 +0800 Subject: [PATCH 20/86] create directory 'data' and taskList.txt and corresponding backup file to collect task data --- data/backup_taskList.txt | 2 ++ data/taskList.txt | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 data/backup_taskList.txt create mode 100644 data/taskList.txt diff --git a/data/backup_taskList.txt b/data/backup_taskList.txt new file mode 100644 index 000000000..b504fdb5c --- /dev/null +++ b/data/backup_taskList.txt @@ -0,0 +1,2 @@ +1. [T][ ] read 1 +2. [T][ ] 3 diff --git a/data/taskList.txt b/data/taskList.txt new file mode 100644 index 000000000..b504fdb5c --- /dev/null +++ b/data/taskList.txt @@ -0,0 +1,2 @@ +1. [T][ ] read 1 +2. [T][ ] 3 From 12e33abd6c35eb38d9306a1be5ef283288a83c2c Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 22 Sep 2023 14:15:18 +0800 Subject: [PATCH 21/86] output jar file to release ver. 1.0 application --- data/backup_taskList.txt | 4 ++-- data/taskList.txt | 3 +-- src/main/java/META-INF/MANIFEST.MF | 3 +++ src/main/java/duke/Duke.java | 1 - 4 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 src/main/java/META-INF/MANIFEST.MF diff --git a/data/backup_taskList.txt b/data/backup_taskList.txt index b504fdb5c..5ff953534 100644 --- a/data/backup_taskList.txt +++ b/data/backup_taskList.txt @@ -1,2 +1,2 @@ -1. [T][ ] read 1 -2. [T][ ] 3 +1. [T][ ] nono +2. [T][ ] hey diff --git a/data/taskList.txt b/data/taskList.txt index b504fdb5c..128130318 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1,2 +1 @@ -1. [T][ ] read 1 -2. [T][ ] 3 +1. [T][ ] 1 diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 000000000..2c9a9745c --- /dev/null +++ b/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: duke.Duke + diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 6bee17c8d..7aab11f9e 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -218,7 +218,6 @@ private static void printList() throws IOException{ //example 1.[T][X] read book System.out.println((i + 1) + "." + list[i]); }*/ - } private static void printFileContents(String filePath) throws IOException { From e49be039114a0aede0025b4dc613b5947205dcf6 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sun, 24 Sep 2023 19:31:12 +0800 Subject: [PATCH 22/86] modify the clearData method so that it only clear data in the beginning when the file is not empty --- data/backup_taskList.txt | 4 ++-- data/taskList.txt | 3 ++- src/main/java/duke/Duke.java | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/data/backup_taskList.txt b/data/backup_taskList.txt index 5ff953534..502e9c1ca 100644 --- a/data/backup_taskList.txt +++ b/data/backup_taskList.txt @@ -1,2 +1,2 @@ -1. [T][ ] nono -2. [T][ ] hey +1. [T][ ] list +2. [T][ ] 3 diff --git a/data/taskList.txt b/data/taskList.txt index 128130318..502e9c1ca 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1 +1,2 @@ -1. [T][ ] 1 +1. [T][ ] list +2. [T][ ] 3 diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 7aab11f9e..5ccdb6340 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -178,7 +178,9 @@ private static void printByeMessage(){ private static void clearData() throws IOException { Path clearFile = Paths.get("data/taskList.txt"); - Files.write(clearFile, new byte[0], StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); + if (Files.size(clearFile) != 0) { + Files.write(clearFile, new byte[0], StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); + } } private static void backupTaskFile() throws IOException{ From 0e0d08a53d4f1d37ace3799b2631b79f6dd3ce25 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sun, 24 Sep 2023 20:57:21 +0800 Subject: [PATCH 23/86] fixed a bug of inputting consecutive space --- data/taskList.txt | 3 +-- src/main/java/duke/Duke.java | 36 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/data/taskList.txt b/data/taskList.txt index 502e9c1ca..e84f1004d 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1,2 +1 @@ -1. [T][ ] list -2. [T][ ] 3 +1. [T][ ] this is spac diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 5ccdb6340..14c03b055 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -1,12 +1,11 @@ package duke; -import task.Event; -import task.Task; -import task.Deadline; -import task.Todo; +import CommandFormat.Command; +import task.*; import exception.DukeException; + import java.io.FileNotFoundException; import java.io.IOException; @@ -27,20 +26,22 @@ public class Duke { public static void main(String[] args) throws IOException{ printWelcomeMessage(); Scanner keyboard = new Scanner(System.in); - checkAndCreateDataFolder(); - checkAndCreateFile("data\\taskList.txt"); - clearData(); + outputFileInitialization(); + executeCommand(keyboard); + } + private static void executeCommand(Scanner keyboard) { while (true) { int taskNo; - String command = keyboard.nextLine().trim().toLowerCase(); //small letter and remove front and back space - String[] commendSplits = command.split(" "); - if (missingOrExtraTaskDescription(commendSplits)){ + String command = keyboard.nextLine(); + command = Command.formattedCommand(command); + String[] commandSplits = command.split(" "); + if (missingOrExtraTaskDescription(commandSplits)){ continue; } try { - switch (commendSplits[0]) { + switch (commandSplits[0]) { case "bye": printByeMessage(); keyboard.close(); @@ -52,17 +53,17 @@ public static void main(String[] args) throws IOException{ case "mark": // command format e.g. mark 1 - taskNo = getTaskNo(commendSplits[1]); + taskNo = getTaskNo(commandSplits[1]); list[taskNo - 1].setDone(taskNo, taskCount, list); break; case "unmark": - taskNo = getTaskNo(commendSplits[1]); + taskNo = getTaskNo(commandSplits[1]); list[taskNo - 1].setNotDone(taskNo, taskCount, list); break; case "delete": - taskNo = getTaskNo(commendSplits[1]); + taskNo = getTaskNo(commandSplits[1]); deleteTask(taskNo); break; @@ -96,14 +97,19 @@ public static void main(String[] args) throws IOException{ } catch (NullPointerException npe){ System.out.println("Your target task doesn't exist. Please input a correct task."); } catch (DukeException e){ - e.incorrectFormatException(commendSplits[0]); + e.incorrectFormatException(commandSplits[0]); } catch (FileNotFoundException fnf){ System.out.println("Sorry, I cannot find the task source. Please check the task file."); } catch (IOException io){ System.out.println("OMG! Something went wrong! Please check if the source files are available."); } } + } + private static void outputFileInitialization() throws IOException { + checkAndCreateDataFolder(); + checkAndCreateFile("data\\taskList.txt"); + clearData(); //if the output file in not empty } private static int getTaskNo(String taskNum) { From 346d4bfac2a6234793467f0ff82d3947206894cd Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sun, 24 Sep 2023 20:57:43 +0800 Subject: [PATCH 24/86] add command class to take care of command format issue --- src/main/java/CommandFormat/Command.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/CommandFormat/Command.java diff --git a/src/main/java/CommandFormat/Command.java b/src/main/java/CommandFormat/Command.java new file mode 100644 index 000000000..b56b2890f --- /dev/null +++ b/src/main/java/CommandFormat/Command.java @@ -0,0 +1,14 @@ +package CommandFormat; + + +public class Command { + + public static String formattedCommand(String cmd){ + cmd = cmd.trim().toLowerCase(); //small letter and remove front and back space + cmd = cmd.replaceAll("\\s+", " "); //remove if consecutive space + + return cmd; + } + + +} From 59084267f3123e273a4708e43cecc1be9fc227b4 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 6 Oct 2023 15:31:28 +0800 Subject: [PATCH 25/86] introduce command class and make large update to more OO implementation --- data/taskList.txt | 4 +- src/main/java/CommandFormat/Command.java | 14 - src/main/java/META-INF/MANIFEST.MF | 3 - src/main/java/command/AddCommand.java | 10 + src/main/java/command/ByeCommand.java | 15 ++ src/main/java/command/Command.java | 18 ++ src/main/java/command/DeadlineCommand.java | 28 ++ src/main/java/command/DeleteCommand.java | 42 +++ src/main/java/command/EventCommand.java | 29 ++ src/main/java/command/ListCommand.java | 21 ++ src/main/java/command/MarkCommand.java | 26 ++ src/main/java/command/TodoCommand.java | 27 ++ src/main/java/command/UnmarkCommand.java | 25 ++ .../java/commandFormat/CommandFormat.java | 38 +++ src/main/java/commandFormat/CommandType.java | 47 ++++ src/main/java/duke/Duke.java | 250 ++---------------- src/main/java/fileIO/FileIO.java | 58 ++++ src/main/java/message/text.java | 80 ++++++ src/main/java/task/Task.java | 16 +- text-ui-test/EXPECTED.TXT | 29 +- text-ui-test/input.txt | 8 + text-ui-test/runtest.bat | 8 +- 22 files changed, 537 insertions(+), 259 deletions(-) delete mode 100644 src/main/java/CommandFormat/Command.java delete mode 100644 src/main/java/META-INF/MANIFEST.MF create mode 100644 src/main/java/command/AddCommand.java create mode 100644 src/main/java/command/ByeCommand.java create mode 100644 src/main/java/command/Command.java create mode 100644 src/main/java/command/DeadlineCommand.java create mode 100644 src/main/java/command/DeleteCommand.java create mode 100644 src/main/java/command/EventCommand.java create mode 100644 src/main/java/command/ListCommand.java create mode 100644 src/main/java/command/MarkCommand.java create mode 100644 src/main/java/command/TodoCommand.java create mode 100644 src/main/java/command/UnmarkCommand.java create mode 100644 src/main/java/commandFormat/CommandFormat.java create mode 100644 src/main/java/commandFormat/CommandType.java create mode 100644 src/main/java/fileIO/FileIO.java create mode 100644 src/main/java/message/text.java diff --git a/data/taskList.txt b/data/taskList.txt index e84f1004d..aafa1164d 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1 +1,3 @@ -1. [T][ ] this is spac +1. [T][ ] 2 +2. [T][ ] 4 +3. [T][ ] 5 diff --git a/src/main/java/CommandFormat/Command.java b/src/main/java/CommandFormat/Command.java deleted file mode 100644 index b56b2890f..000000000 --- a/src/main/java/CommandFormat/Command.java +++ /dev/null @@ -1,14 +0,0 @@ -package CommandFormat; - - -public class Command { - - public static String formattedCommand(String cmd){ - cmd = cmd.trim().toLowerCase(); //small letter and remove front and back space - cmd = cmd.replaceAll("\\s+", " "); //remove if consecutive space - - return cmd; - } - - -} diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF deleted file mode 100644 index 2c9a9745c..000000000 --- a/src/main/java/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: duke.Duke - diff --git a/src/main/java/command/AddCommand.java b/src/main/java/command/AddCommand.java new file mode 100644 index 000000000..7feef828a --- /dev/null +++ b/src/main/java/command/AddCommand.java @@ -0,0 +1,10 @@ +package command; + +public abstract class AddCommand extends Command { + protected String command; + + public AddCommand(String cmd){ + super(false); + this.command = cmd; + } +} diff --git a/src/main/java/command/ByeCommand.java b/src/main/java/command/ByeCommand.java new file mode 100644 index 000000000..8a3b2b35d --- /dev/null +++ b/src/main/java/command/ByeCommand.java @@ -0,0 +1,15 @@ +package command; + +import message.text; + +public class ByeCommand extends Command { + + public ByeCommand() { + super(true); + } + + @Override + public void executeCommand() { + text.printByeMessage(); + } +} diff --git a/src/main/java/command/Command.java b/src/main/java/command/Command.java new file mode 100644 index 000000000..f589c65c5 --- /dev/null +++ b/src/main/java/command/Command.java @@ -0,0 +1,18 @@ +package command; + +import java.io.IOException; + +public abstract class Command { + private boolean isExit; + + public Command(boolean isExit){ + this.isExit = isExit; + } + + public boolean isExit(){ + return isExit; + } + + public abstract void executeCommand() throws IOException; +} + diff --git a/src/main/java/command/DeadlineCommand.java b/src/main/java/command/DeadlineCommand.java new file mode 100644 index 000000000..de06d471b --- /dev/null +++ b/src/main/java/command/DeadlineCommand.java @@ -0,0 +1,28 @@ +package command; + +import duke.Duke; +import exception.DukeException; +import message.text; +import task.Deadline; + +import java.io.IOException; + +public class DeadlineCommand extends AddCommand { + + public DeadlineCommand(String ddlCmd){ + super(ddlCmd); + } + + @Override + public void executeCommand(){ + try { + Duke.list[Duke.taskCount] = Deadline.newDdl(this.command); + text.createTaskSuccessMsg(); + } catch (DukeException e) { + e.incorrectFormatException("deadline"); + } catch (IOException io){ + System.out.println("OMG! Something went wrong! Please check if the source files are available."); + } + + } +} diff --git a/src/main/java/command/DeleteCommand.java b/src/main/java/command/DeleteCommand.java new file mode 100644 index 000000000..13dd4f55c --- /dev/null +++ b/src/main/java/command/DeleteCommand.java @@ -0,0 +1,42 @@ +package command; + +import duke.Duke; +import message.text; +import task.Task; + +import java.io.IOException; + +import static commandFormat.CommandFormat.getTaskNo; +import static fileIO.FileIO.overwriteToFile; + + +public class DeleteCommand extends Command{ + + private final String index; + + public DeleteCommand(String index) { + super(false); + this.index = index; + } + + @Override + public void executeCommand() throws IOException { + try { + int deleteIndex = getTaskNo(this.index); + deleteTask(deleteIndex); + } catch (NumberFormatException nfe) { + System.out.println("Hey, please input your command with the correct task number."); + } + } + + private static void deleteTask(int deleteIndex) throws IOException{ + if (deleteIndex <= 0 || deleteIndex> Duke.taskCount){ + System.out.println("Oh, No! invalid index! You don't have that task. Please try again."); + return; + } + text.deleteTaskSuccessMsg(deleteIndex); + Duke.list = Task.updatedTaskList(deleteIndex - 1); + overwriteToFile("data/taskList.txt", Task.getConcatenateTasks()); + } + +} diff --git a/src/main/java/command/EventCommand.java b/src/main/java/command/EventCommand.java new file mode 100644 index 000000000..12379a8d2 --- /dev/null +++ b/src/main/java/command/EventCommand.java @@ -0,0 +1,29 @@ +package command; + +import duke.Duke; +import exception.DukeException; +import message.text; +import task.Event; + +import java.io.IOException; + +public class EventCommand extends AddCommand { + + public EventCommand(String eventTask){ + super(eventTask); + } + + @Override + public void executeCommand(){ + try { + Duke.list[Duke.taskCount] = Event.newEventTask(this.command); + text.createTaskSuccessMsg(); + } catch (DukeException e) { + e.incorrectFormatException("event"); + } catch (IOException io){ + System.out.println("OMG! Something went wrong! Please check if the source files are available."); + } + } + + +} diff --git a/src/main/java/command/ListCommand.java b/src/main/java/command/ListCommand.java new file mode 100644 index 000000000..cf34da354 --- /dev/null +++ b/src/main/java/command/ListCommand.java @@ -0,0 +1,21 @@ +package command; + +import message.text; + +import java.io.IOException; + +public class ListCommand extends Command { + + public ListCommand(){ + super(false); + } + + @Override + public void executeCommand() { + try { + text.printList(); + } catch (IOException io) { + System.out.println("OMG! Something went wrong! Please check if the source files are available."); + } + } +} diff --git a/src/main/java/command/MarkCommand.java b/src/main/java/command/MarkCommand.java new file mode 100644 index 000000000..c8bb149ef --- /dev/null +++ b/src/main/java/command/MarkCommand.java @@ -0,0 +1,26 @@ +package command; + +import duke.Duke; + +import static commandFormat.CommandFormat.getTaskNo; + +public class MarkCommand extends Command { + + private String index; + + public MarkCommand(String index) { + super(false); + this.index = index; + } + + @Override + public void executeCommand() { + try { + int taskNo = getTaskNo(this.index); + Duke.list[taskNo - 1].setDone(taskNo, Duke.taskCount, Duke.list); + } catch (NumberFormatException nfe) { + System.out.println("Hey, please input your command with the correct task number."); + } + } + +} diff --git a/src/main/java/command/TodoCommand.java b/src/main/java/command/TodoCommand.java new file mode 100644 index 000000000..1a224440d --- /dev/null +++ b/src/main/java/command/TodoCommand.java @@ -0,0 +1,27 @@ +package command; + +import duke.Duke; +import exception.DukeException; +import message.text; +import task.Todo; + +import java.io.IOException; + +public class TodoCommand extends AddCommand{ + + public TodoCommand(String todoCmd){ + super(todoCmd); + } + + @Override + public void executeCommand(){ + try { + Duke.list[Duke.taskCount] = Todo.newTodoTask(this.command); + text.createTaskSuccessMsg(); + } catch (DukeException e) { + e.incorrectFormatException("todo"); + } catch (IOException io){ + System.out.println("OMG! Something went wrong! Please check if the source files are available."); + } + } +} diff --git a/src/main/java/command/UnmarkCommand.java b/src/main/java/command/UnmarkCommand.java new file mode 100644 index 000000000..4cadf3cd1 --- /dev/null +++ b/src/main/java/command/UnmarkCommand.java @@ -0,0 +1,25 @@ +package command; + +import duke.Duke; + +import static commandFormat.CommandFormat.getTaskNo; + +public class UnmarkCommand extends Command{ + + private String index; + + public UnmarkCommand(String index) { + super(false); + this.index = index; + } + + @Override + public void executeCommand() { + try { + int taskNo = getTaskNo(this.index); + Duke.list[taskNo - 1].setNotDone(taskNo, Duke.taskCount, Duke.list); + } catch (NumberFormatException nfe) { + System.out.println("Hey, please input your command with the correct task number."); + } + } +} diff --git a/src/main/java/commandFormat/CommandFormat.java b/src/main/java/commandFormat/CommandFormat.java new file mode 100644 index 000000000..e143c9d69 --- /dev/null +++ b/src/main/java/commandFormat/CommandFormat.java @@ -0,0 +1,38 @@ +package commandFormat; + + +public class CommandFormat { + + public static String formattedCommand(String cmd){ + cmd = cmd.trim().toLowerCase(); //small letter and remove front and back space + cmd = cmd.replaceAll("\\s+", " "); //remove if consecutive space + + return cmd; + } + + public static int getTaskNo(String taskNum) { + //exception: taskNum is not number, or containing non-numerical value + return Integer.parseInt(taskNum); + } + + //To tackle cases of invalid input like 'todo', 'event', etc. + public static boolean missingOrExtraTaskDescription(String[] cmd){ + if (cmd.length == 1){ + if(cmd[0].equals("todo") || cmd[0].equals("event") || cmd[0].equals("deadline") + || cmd[0].equals("mark") || cmd[0].equals("unmark") || cmd[0].equals("delete")){ + System.out.println("Please describe your target."); + return true; + } + } + else if (cmd.length>=2 && cmd[0].equals("list") ){ + System.out.println("Do you mean to see the list? Please try again using 'list'."); + return true; + }else if (cmd.length>=2 && cmd[0].equals("save") ){ + System.out.println("Do you mean to save the tasks? Please try again using 'save'."); + return true; + } + return false; + } + + +} diff --git a/src/main/java/commandFormat/CommandType.java b/src/main/java/commandFormat/CommandType.java new file mode 100644 index 000000000..c62631c3c --- /dev/null +++ b/src/main/java/commandFormat/CommandType.java @@ -0,0 +1,47 @@ +package commandFormat; + +import command.*; +import exception.DukeException; + +public class CommandType { + + public static Command parseCommand(String input) throws DukeException { + + String cmd = CommandFormat.formattedCommand(input); + String[] commandSplits = cmd.split(" "); + Command command; + + switch (commandSplits[0]) { + case "list": + command = new ListCommand(); + break; + case "todo": + command = new TodoCommand(cmd); + break; + case "deadline": + command = new DeadlineCommand(cmd); + break; + case "event": + command = new EventCommand(cmd); + break; + case "mark": + command = new MarkCommand(commandSplits[1]); + break; + case "unmark": + command = new UnmarkCommand(commandSplits[1]); + break; + case "delete": + command = new DeleteCommand(commandSplits[1]); + break; + case "bye": + command = new ByeCommand(); + break; + default: + throw new DukeException(); + } + + return command; + } + + +} diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 14c03b055..7878b343a 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -1,97 +1,52 @@ package duke; -import CommandFormat.Command; +import command.Command; +import commandFormat.CommandFormat; +import commandFormat.CommandType; import task.*; +import message.text; import exception.DukeException; - import java.io.FileNotFoundException; import java.io.IOException; -import java.io.File; -import java.io.FileWriter; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; -import java.nio.file.StandardCopyOption; import java.util.Scanner; +import fileIO.FileIO; + + public class Duke { public static int taskCount = 0; - private static Task[] list = new Task[100]; + public static Task[] list = new Task[100]; public static void main(String[] args) throws IOException{ - printWelcomeMessage(); + text.printWelcomeMessage(); Scanner keyboard = new Scanner(System.in); - outputFileInitialization(); + FileIO.outputFileInitialization(); executeCommand(keyboard); } private static void executeCommand(Scanner keyboard) { - while (true) { + boolean isExit = false; + + while (!isExit) { int taskNo; - String command = keyboard.nextLine(); - command = Command.formattedCommand(command); - String[] commandSplits = command.split(" "); - if (missingOrExtraTaskDescription(commandSplits)){ + String cmd = keyboard.nextLine(); + cmd = CommandFormat.formattedCommand(cmd); + String[] commandSplits = cmd.split(" "); + if (CommandFormat.missingOrExtraTaskDescription(commandSplits)){ continue; } try { - switch (commandSplits[0]) { - case "bye": - printByeMessage(); - keyboard.close(); - return; - - case "list": - printList(); - break; - - case "mark": - // command format e.g. mark 1 - taskNo = getTaskNo(commandSplits[1]); - list[taskNo - 1].setDone(taskNo, taskCount, list); - break; - - case "unmark": - taskNo = getTaskNo(commandSplits[1]); - list[taskNo - 1].setNotDone(taskNo, taskCount, list); - break; - - case "delete": - taskNo = getTaskNo(commandSplits[1]); - deleteTask(taskNo); - break; - - case "todo": - // command format e.g. todo borrow book - list[taskCount] = Todo.newTodoTask(command); - createTaskSuccessMsg(); - break; - - case "deadline": - // command e.g. deadline return book /by Sunday - list[taskCount] = Deadline.newDdl(command); - createTaskSuccessMsg(); - break; - - case "event": - //command e.g. event project meeting /from Mon 2pm /to 4pm - list[taskCount] = Event.newEventTask(command); - createTaskSuccessMsg(); - break; - - case "save": - backupTaskFile(); - break; - - default: - throw new DukeException(); - } + Command command = CommandType.parseCommand(cmd); + command.executeCommand(); + isExit = command.isExit(); + // case "save": + // backupTaskFile(); + // break; } catch (NumberFormatException nfe) { System.out.println("Hey, please input your command with the correct task number."); } catch (NullPointerException npe){ @@ -106,164 +61,5 @@ private static void executeCommand(Scanner keyboard) { } } - private static void outputFileInitialization() throws IOException { - checkAndCreateDataFolder(); - checkAndCreateFile("data\\taskList.txt"); - clearData(); //if the output file in not empty - } - - private static int getTaskNo(String taskNum) { - //exception: taskNum is not number, or containing non-numerical value - return Integer.parseInt(taskNum); - } - - public static Task[] getTaskList() { - return list; - } - - private static void deleteTask(int deleteIndex) throws IOException{ - if (deleteIndex <= 0 || deleteIndex> Duke.taskCount){ - System.out.println("Oh, No! invalid index! You don't have that task. Please try again."); - return; - } - deleteTaskSuccessMsg(deleteIndex); - list = Task.updatedTaskList(deleteIndex - 1); - overwriteToFile("data/taskList.txt", getConcatenateTasks()); - } - - //This method will return all tasks inside the list - private static String getConcatenateTasks() { - StringBuilder stringBuilder = new StringBuilder(); - for (int i = 0; i < taskCount; i++) { - String taskAppend = (i +1) + ". " + list[i].toString(); - stringBuilder.append(taskAppend).append("\n"); - } - return stringBuilder.toString(); - } - - //To tackle cases of invalid input like 'todo', 'event', etc. - private static boolean missingOrExtraTaskDescription(String[] cmd){ - if (cmd.length == 1){ - if(cmd[0].equals("todo") || cmd[0].equals("event") || cmd[0].equals("deadline") - || cmd[0].equals("mark") || cmd[0].equals("unmark") || cmd[0].equals("delete")){ - System.out.println("Please describe your target."); - return true; - } - } - else if (cmd.length>=2 && cmd[0].equals("list") ){ - System.out.println("Do you mean to see the list? Please try again using 'list'."); - return true; - }else if (cmd.length>=2 && cmd[0].equals("save") ){ - System.out.println("Do you mean to save the tasks? Please try again using 'save'."); - return true; - } - return false; - } - - private static void createTaskSuccessMsg() throws IOException{ - System.out.println("Got it. I've added this task:"); - System.out.println(list[taskCount]); - taskCount++; - System.out.println("Now you have " + taskCount + " tasks in the list."); - - String taskAppend = taskCount + ". " + list[taskCount - 1].toString() + "\n"; - writeToFile("data/taskList.txt", taskAppend); - } - - private static void deleteTaskSuccessMsg(int deleteIndex) { - System.out.println("Noted. I've removed this task:"); - System.out.println(list[deleteIndex - 1]); - taskCount--; - System.out.println("Now you have " + taskCount + " tasks in the list."); - } - - - private static void printByeMessage(){ - System.out.println("Bye. Hope to see you again soon!"); - } - - private static void clearData() throws IOException { - Path clearFile = Paths.get("data/taskList.txt"); - if (Files.size(clearFile) != 0) { - Files.write(clearFile, new byte[0], StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); - } - } - - private static void backupTaskFile() throws IOException{ - Path sourcePath = Paths.get("data/taskList.txt"); - Path targetPath = Paths.get("data/backup_taskList.txt"); - Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); //if file not exist, create one; - System.out.println("Great! I have saved the current tasks."); - } - - private static void printWelcomeMessage() { - System.out.println("Hello! I'm Oriento."); - System.out.println("What can I help you?"); - System.out.println("⣿⣿⣿⠟⠛⠛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢋⣩⣉⢻⣿\n" + - "⣿⣿⣿⠀⣿⣶⣕⣈⠹⠿⠿⠿⠿⠟⠛⣛⢋⣰⠣⣿⣿⠀⣿⣿\n" + - "⣿⣿⣿⡀⣿⣿⣿⣧⢻⣿⣶⣷⣿⣿⣿⣿⣿⣿⠿⠶⡝⠀⣿⣿\n" + - "⣿⣿⣿⣷⠘⣿⣿⣿⢏⣿⣿⣋⣀⣈⣻⣿⣿⣷⣤⣤⣿⡐⢿⣿\n" + - "⣿⣿⣿⣿⣆⢩⣝⣫⣾⣿⣿⣿⣿⡟⠿⠿⠦⠀⠸⠿⣻⣿⡄⢻⣿\n" + - "⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⠇⣼⣿\n" + - "⣿⣿⣿⣿⣿⣿⡄⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣰⣿\n" + - "⣿⣿⣿⣿⣿⣿⠇⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣿⣿\n" + - "⣿⣿⣿⣿⣿⠏⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢸⣿⣿\n" + - "⣿⣿⣿⣿⠟⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⣿⣿\n" + - "⣿⣿⣿⠋⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⣿⣿\n" + - "⣿⣿⠋⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿\n"); - } - - private static void printList() throws IOException{ - if (taskCount == 0){ - System.out.println("You don't have any tasks now. Do you want to add a new task?"); - return; - } - printFileContents("data/taskList.txt"); - - // This is to print the whole task message directly - /* - for (int i = 0; i < count; i++) { - //example 1.[T][X] read book - System.out.println((i + 1) + "." + list[i]); - }*/ - } - - private static void printFileContents(String filePath) throws IOException { - File f = new File(filePath); // create a File for the given file path - Scanner s = new Scanner(f); // create a Scanner using the File as the source - while (s.hasNext()) { - System.out.println(s.nextLine()); - } - } - - private static void writeToFile(String filePath, String taskAppend) throws IOException { - FileWriter fw = new FileWriter(filePath, true); - fw.write(taskAppend); - fw.close(); - } - - private static void overwriteToFile(String filePath, String taskAppend) throws IOException { - FileWriter fw = new FileWriter(filePath); - fw.write(taskAppend); - fw.close(); - } - - public static void checkAndCreateFile(String path) throws IOException { - File f = new File(path); - if(!f.exists()){ - if(!f.createNewFile()){ - throw new IOException(); - } - } - } - - public static void checkAndCreateDataFolder() throws IOException { - File folder = new File("data"); - if (!folder.isDirectory()) { - if(!folder.mkdirs()){ - throw new IOException(); - } - } - } } diff --git a/src/main/java/fileIO/FileIO.java b/src/main/java/fileIO/FileIO.java new file mode 100644 index 000000000..6f5323c51 --- /dev/null +++ b/src/main/java/fileIO/FileIO.java @@ -0,0 +1,58 @@ +package fileIO; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.nio.file.StandardCopyOption; + +public class FileIO { + + public static void outputFileInitialization() throws IOException { + checkAndCreateDataFolder(); + checkAndCreateFile("data\\taskList.txt"); + clearData(); //if the output file in not empty + } + + private static void checkAndCreateFile(String path) throws IOException { + File f = new File(path); + if(!f.exists()){ + if(!f.createNewFile()){ + throw new IOException(); + } + } + } + + private static void checkAndCreateDataFolder() throws IOException { + File folder = new File("data"); + if (!folder.isDirectory()) { + if(!folder.mkdirs()){ + throw new IOException(); + } + } + } + + private static void backupTaskFile() throws IOException{ + Path sourcePath = Paths.get("data/taskList.txt"); + Path targetPath = Paths.get("data/backup_taskList.txt"); + Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); //if file not exist, create one; + System.out.println("Great! I have saved the current tasks."); + } + + private static void clearData() throws IOException { + Path clearFile = Paths.get("data/taskList.txt"); + if (Files.size(clearFile) != 0) { + Files.write(clearFile, new byte[0], StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); + } + } + + public static void overwriteToFile(String filePath, String taskAppend) throws IOException { + FileWriter fw = new FileWriter(filePath); + fw.write(taskAppend); + fw.close(); + } +} diff --git a/src/main/java/message/text.java b/src/main/java/message/text.java new file mode 100644 index 000000000..486b5ad42 --- /dev/null +++ b/src/main/java/message/text.java @@ -0,0 +1,80 @@ +package message; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Scanner; + +import static duke.Duke.list; +import static duke.Duke.taskCount; + +public class text { + + public static void printWelcomeMessage() { + System.out.println("Hello! I'm Oriento."); + System.out.println("What can I help you?"); + System.out.println("⣿⣿⣿⠟⠛⠛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢋⣩⣉⢻⣿\n" + + "⣿⣿⣿⠀⣿⣶⣕⣈⠹⠿⠿⠿⠿⠟⠛⣛⢋⣰⠣⣿⣿⠀⣿⣿\n" + + "⣿⣿⣿⡀⣿⣿⣿⣧⢻⣿⣶⣷⣿⣿⣿⣿⣿⣿⠿⠶⡝⠀⣿⣿\n" + + "⣿⣿⣿⣷⠘⣿⣿⣿⢏⣿⣿⣋⣀⣈⣻⣿⣿⣷⣤⣤⣿⡐⢿⣿\n" + + "⣿⣿⣿⣿⣆⢩⣝⣫⣾⣿⣿⣿⣿⡟⠿⠿⠦⠀⠸⠿⣻⣿⡄⢻⣿\n" + + "⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⠇⣼⣿\n" + + "⣿⣿⣿⣿⣿⣿⡄⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣰⣿\n" + + "⣿⣿⣿⣿⣿⣿⠇⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣿⣿\n" + + "⣿⣿⣿⣿⣿⠏⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢸⣿⣿\n" + + "⣿⣿⣿⣿⠟⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⣿⣿\n" + + "⣿⣿⣿⠋⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⣿⣿\n" + + "⣿⣿⠋⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿\n"); + } + + public static void printByeMessage(){ + System.out.println("Bye. Hope to see you again soon!"); + } + + private static void printFileContents(String filePath) throws IOException { + File f = new File(filePath); // create a File for the given file path + Scanner s = new Scanner(f); // create a Scanner using the File as the source + while (s.hasNext()) { + System.out.println(s.nextLine()); + } + } + + public static void printList() throws IOException{ + if (taskCount == 0){ + System.out.println("You don't have any tasks now. Do you want to add a new task?"); + return; + } + printFileContents("data/taskList.txt"); + + // This is to print the whole task message directly + /* + for (int i = 0; i < count; i++) { + //example 1.[T][X] read book + System.out.println((i + 1) + "." + list[i]); + }*/ + } + + public static void createTaskSuccessMsg() throws IOException{ + System.out.println("Got it. I've added this task:"); + System.out.println(list[taskCount]); + taskCount++; + System.out.println("Now you have " + taskCount + " tasks in the list."); + + String taskAppend = taskCount + ". " + list[taskCount - 1].toString() + "\n"; + writeToFile("data/taskList.txt", taskAppend); + } + + private static void writeToFile(String filePath, String taskAppend) throws IOException { + FileWriter fw = new FileWriter(filePath, true); + fw.write(taskAppend); + fw.close(); + } + + public static void deleteTaskSuccessMsg(int deleteIndex) { + System.out.println("Noted. I've removed this task:"); + System.out.println(list[deleteIndex - 1]); + taskCount--; + System.out.println("Now you have " + taskCount + " tasks in the list."); + } + +} diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java index 529604a93..a2c6541f6 100644 --- a/src/main/java/task/Task.java +++ b/src/main/java/task/Task.java @@ -43,12 +43,22 @@ public void setNotDone(int taskNo, int taskCount, Task[] list) { //return a new list after delete the target object public static Task[] updatedTaskList(int indexOfDelete){ Task[] newList = new Task[100]; - int numOfCopy = Duke.getTaskList().length - indexOfDelete - 1; - System.arraycopy(Duke.getTaskList(), 0, newList, 0, indexOfDelete); - System.arraycopy(Duke.getTaskList(), indexOfDelete + 1, newList, indexOfDelete, numOfCopy); + int numOfCopy = Duke.list.length - indexOfDelete - 1; + System.arraycopy(Duke.list, 0, newList, 0, indexOfDelete); + System.arraycopy(Duke.list, indexOfDelete + 1, newList, indexOfDelete, numOfCopy); return newList; } + //This method will return all tasks inside the list + public static String getConcatenateTasks() { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < Duke.taskCount; i++) { + String taskAppend = (i +1) + ". " + Duke.list[i].toString(); + stringBuilder.append(taskAppend).append("\n"); + } + return stringBuilder.toString(); + } + @Override public String toString() { return "[" + this.getStatusIcon() + "] " + this.description; diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 657e74f6e..2a13a1132 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,7 +1,22 @@ -Hello from - ____ _ -| _ \ _ _| | _____ -| | | | | | | |/ / _ \ -| |_| | |_| | < __/ -|____/ \__,_|_|\_\___| - +Hello! I'm Oriento. +What can I do for you? +Got it. I've added this task: +[T][ ] read book +Now you have 1 tasks in the list. +Got it. I've added this task: +[T][ ] play piano +Now you have 2 tasks in the list. + Nice! I've marked this task as done: + [X] play piano +Got it. I've added this task: +[D][ ] return book (by: Friday) +Now you have 3 tasks in the list. +Got it. I've added this task: +[E][ ] java lesson (from: Friday 4pm to: 6pm) +Now you have 4 tasks in the list. +Oh, you haven't finished this yet. +1.[T][ ] read book +2.[T][X] play piano +3.[D][ ] return book (by: Friday) +4.[E][ ] java lesson (from: Friday 4pm to: 6pm) +Bye. Hope to see you again soon! diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index e69de29bb..eb726634e 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -0,0 +1,8 @@ +todo read book +todo play piano +mark 2 +deadline return book /by Friday +event java lesson /from Friday 4pm /to 6pm +unmark 4 +list +bye diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat index a230843b0..0b643f82e 100644 --- a/text-ui-test/runtest.bat +++ b/text-ui-test/runtest.bat @@ -4,10 +4,10 @@ REM create bin directory if it doesn't exist if not exist ..\bin mkdir ..\bin REM delete output from previous run -if exist ACTUAL.TXT del ACTUAL.TXT +del ACTUAL.TXT REM compile the code into the bin folder -javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\duke\*.java ..\src\main\java\exception\*.java ..\src\main\java\task\*.java +javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java IF ERRORLEVEL 1 ( echo ********** BUILD FAILURE ********** exit /b 1 @@ -15,7 +15,7 @@ IF ERRORLEVEL 1 ( REM no error here, errorlevel == 0 REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT -java -classpath ..\bin duke.Duke < input.txt > ACTUAL.TXT +java -classpath ..\bin Duke < input.txt > ACTUAL.TXT REM compare the output to the expected output -FC ACTUAL.TXT EXPECTED.TXT +FC ACTUAL.TXT EXPECTED.TXT \ No newline at end of file From 8c9a743796fe2d6e6df2b05c9ebe7fbb68342d88 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 6 Oct 2023 21:05:26 +0800 Subject: [PATCH 26/86] add time praser functionality --- data/backup_taskList.txt | 2 - data/taskList.txt | 3 - src/main/java/command/ByeCommand.java | 11 +- src/main/java/command/DeadlineCommand.java | 4 +- src/main/java/command/DeleteCommand.java | 4 +- src/main/java/command/EventCommand.java | 4 +- src/main/java/command/ListCommand.java | 4 +- src/main/java/command/TodoCommand.java | 4 +- src/main/java/commandFormat/CommandType.java | 9 +- src/main/java/commandFormat/TimeParser.java | 22 ++++ src/main/java/duke/Duke.java | 10 +- src/main/java/fileIO/FileIO.java | 112 +++++++++++++++++- .../java/message/{text.java => Text.java} | 13 +- src/main/java/task/Deadline.java | 18 ++- src/main/java/task/Event.java | 15 ++- src/main/java/task/Task.java | 4 + 16 files changed, 186 insertions(+), 53 deletions(-) create mode 100644 src/main/java/commandFormat/TimeParser.java rename src/main/java/message/{text.java => Text.java} (92%) diff --git a/data/backup_taskList.txt b/data/backup_taskList.txt index 502e9c1ca..e69de29bb 100644 --- a/data/backup_taskList.txt +++ b/data/backup_taskList.txt @@ -1,2 +0,0 @@ -1. [T][ ] list -2. [T][ ] 3 diff --git a/data/taskList.txt b/data/taskList.txt index aafa1164d..e69de29bb 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1,3 +0,0 @@ -1. [T][ ] 2 -2. [T][ ] 4 -3. [T][ ] 5 diff --git a/src/main/java/command/ByeCommand.java b/src/main/java/command/ByeCommand.java index 8a3b2b35d..e6a4d7870 100644 --- a/src/main/java/command/ByeCommand.java +++ b/src/main/java/command/ByeCommand.java @@ -1,6 +1,10 @@ package command; -import message.text; +import message.Text; + +import java.io.IOException; +import fileIO.FileIO; + public class ByeCommand extends Command { @@ -10,6 +14,9 @@ public ByeCommand() { @Override public void executeCommand() { - text.printByeMessage(); + + Text.printByeMessage(); + FileIO.backupTaskFile(); + } } diff --git a/src/main/java/command/DeadlineCommand.java b/src/main/java/command/DeadlineCommand.java index de06d471b..391e32d76 100644 --- a/src/main/java/command/DeadlineCommand.java +++ b/src/main/java/command/DeadlineCommand.java @@ -2,7 +2,7 @@ import duke.Duke; import exception.DukeException; -import message.text; +import message.Text; import task.Deadline; import java.io.IOException; @@ -17,7 +17,7 @@ public DeadlineCommand(String ddlCmd){ public void executeCommand(){ try { Duke.list[Duke.taskCount] = Deadline.newDdl(this.command); - text.createTaskSuccessMsg(); + Text.createTaskSuccessMsg(); } catch (DukeException e) { e.incorrectFormatException("deadline"); } catch (IOException io){ diff --git a/src/main/java/command/DeleteCommand.java b/src/main/java/command/DeleteCommand.java index 13dd4f55c..73245c6d1 100644 --- a/src/main/java/command/DeleteCommand.java +++ b/src/main/java/command/DeleteCommand.java @@ -1,7 +1,7 @@ package command; import duke.Duke; -import message.text; +import message.Text; import task.Task; import java.io.IOException; @@ -34,7 +34,7 @@ private static void deleteTask(int deleteIndex) throws IOException{ System.out.println("Oh, No! invalid index! You don't have that task. Please try again."); return; } - text.deleteTaskSuccessMsg(deleteIndex); + Text.deleteTaskSuccessMsg(deleteIndex); Duke.list = Task.updatedTaskList(deleteIndex - 1); overwriteToFile("data/taskList.txt", Task.getConcatenateTasks()); } diff --git a/src/main/java/command/EventCommand.java b/src/main/java/command/EventCommand.java index 12379a8d2..ef660ade5 100644 --- a/src/main/java/command/EventCommand.java +++ b/src/main/java/command/EventCommand.java @@ -2,7 +2,7 @@ import duke.Duke; import exception.DukeException; -import message.text; +import message.Text; import task.Event; import java.io.IOException; @@ -17,7 +17,7 @@ public EventCommand(String eventTask){ public void executeCommand(){ try { Duke.list[Duke.taskCount] = Event.newEventTask(this.command); - text.createTaskSuccessMsg(); + Text.createTaskSuccessMsg(); } catch (DukeException e) { e.incorrectFormatException("event"); } catch (IOException io){ diff --git a/src/main/java/command/ListCommand.java b/src/main/java/command/ListCommand.java index cf34da354..4ae5ee843 100644 --- a/src/main/java/command/ListCommand.java +++ b/src/main/java/command/ListCommand.java @@ -1,6 +1,6 @@ package command; -import message.text; +import message.Text; import java.io.IOException; @@ -13,7 +13,7 @@ public ListCommand(){ @Override public void executeCommand() { try { - text.printList(); + Text.printList(); } catch (IOException io) { System.out.println("OMG! Something went wrong! Please check if the source files are available."); } diff --git a/src/main/java/command/TodoCommand.java b/src/main/java/command/TodoCommand.java index 1a224440d..65cc7e02e 100644 --- a/src/main/java/command/TodoCommand.java +++ b/src/main/java/command/TodoCommand.java @@ -2,7 +2,7 @@ import duke.Duke; import exception.DukeException; -import message.text; +import message.Text; import task.Todo; import java.io.IOException; @@ -17,7 +17,7 @@ public TodoCommand(String todoCmd){ public void executeCommand(){ try { Duke.list[Duke.taskCount] = Todo.newTodoTask(this.command); - text.createTaskSuccessMsg(); + Text.createTaskSuccessMsg(); } catch (DukeException e) { e.incorrectFormatException("todo"); } catch (IOException io){ diff --git a/src/main/java/commandFormat/CommandType.java b/src/main/java/commandFormat/CommandType.java index c62631c3c..1ae3c2fc1 100644 --- a/src/main/java/commandFormat/CommandType.java +++ b/src/main/java/commandFormat/CommandType.java @@ -7,8 +7,7 @@ public class CommandType { public static Command parseCommand(String input) throws DukeException { - String cmd = CommandFormat.formattedCommand(input); - String[] commandSplits = cmd.split(" "); + String[] commandSplits = input.split(" "); Command command; switch (commandSplits[0]) { @@ -16,13 +15,13 @@ public static Command parseCommand(String input) throws DukeException { command = new ListCommand(); break; case "todo": - command = new TodoCommand(cmd); + command = new TodoCommand(input); break; case "deadline": - command = new DeadlineCommand(cmd); + command = new DeadlineCommand(input); break; case "event": - command = new EventCommand(cmd); + command = new EventCommand(input); break; case "mark": command = new MarkCommand(commandSplits[1]); diff --git a/src/main/java/commandFormat/TimeParser.java b/src/main/java/commandFormat/TimeParser.java new file mode 100644 index 000000000..0e0bc49c2 --- /dev/null +++ b/src/main/java/commandFormat/TimeParser.java @@ -0,0 +1,22 @@ +package commandFormat; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; + +public class TimeParser { + + public static LocalDateTime parseDateTime(String input) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy Hmm"); + return LocalDateTime.parse(input, formatter); + } + + public static String convertDateTimetoString(LocalDateTime dateTime) { + return dateTime.format(DateTimeFormatter.ofPattern("MMM d yyyy hh:mm a")); + } + + +} + + diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 7878b343a..98b82f3e7 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -5,7 +5,7 @@ import commandFormat.CommandFormat; import commandFormat.CommandType; import task.*; -import message.text; +import message.Text; import exception.DukeException; import java.io.FileNotFoundException; @@ -21,8 +21,8 @@ public class Duke { public static int taskCount = 0; public static Task[] list = new Task[100]; - public static void main(String[] args) throws IOException{ - text.printWelcomeMessage(); + public static void main(String[] args) throws IOException, DukeException { + Text.printWelcomeMessage(); Scanner keyboard = new Scanner(System.in); FileIO.outputFileInitialization(); executeCommand(keyboard); @@ -32,7 +32,6 @@ private static void executeCommand(Scanner keyboard) { boolean isExit = false; while (!isExit) { - int taskNo; String cmd = keyboard.nextLine(); cmd = CommandFormat.formattedCommand(cmd); String[] commandSplits = cmd.split(" "); @@ -44,9 +43,6 @@ private static void executeCommand(Scanner keyboard) { Command command = CommandType.parseCommand(cmd); command.executeCommand(); isExit = command.isExit(); - // case "save": - // backupTaskFile(); - // break; } catch (NumberFormatException nfe) { System.out.println("Hey, please input your command with the correct task number."); } catch (NullPointerException npe){ diff --git a/src/main/java/fileIO/FileIO.java b/src/main/java/fileIO/FileIO.java index 6f5323c51..23a2ecfd7 100644 --- a/src/main/java/fileIO/FileIO.java +++ b/src/main/java/fileIO/FileIO.java @@ -1,21 +1,32 @@ package fileIO; +import duke.Duke; +import exception.DukeException; +import task.Todo; +import message.Text; + import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.nio.file.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.nio.file.StandardCopyOption; +import java.time.LocalDateTime; +import java.util.Scanner; + public class FileIO { - public static void outputFileInitialization() throws IOException { + public static void outputFileInitialization() throws IOException, DukeException { checkAndCreateDataFolder(); checkAndCreateFile("data\\taskList.txt"); + checkAndCreateFile("data/backup_taskList.txt"); clearData(); //if the output file in not empty + restoreSavedData("data/backup_taskList.txt"); } private static void checkAndCreateFile(String path) throws IOException { @@ -36,11 +47,22 @@ private static void checkAndCreateDataFolder() throws IOException { } } - private static void backupTaskFile() throws IOException{ - Path sourcePath = Paths.get("data/taskList.txt"); - Path targetPath = Paths.get("data/backup_taskList.txt"); - Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); //if file not exist, create one; - System.out.println("Great! I have saved the current tasks."); + public static void backupTaskFile() { + // Path sourcePath = Paths.get("data/taskList.txt"); + //Path targetPath = Paths.get("data/backup_taskList.txt"); + // Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); //if file not exist, create one; + try { + File src = new File("data\\taskList.txt"); + File dst = new File("data\\backup_taskList.txt"); + copyFile(src, dst); + System.out.println("Great! I have saved the current tasks."); + } catch (IOException e) { + System.out.println("Oh No! I cannot save the file. Please check if the backup file is available."); + } + } + + private static void copyFile(File source, File dest) throws IOException { + Files.copy(source.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); } private static void clearData() throws IOException { @@ -55,4 +77,82 @@ public static void overwriteToFile(String filePath, String taskAppend) throws IO fw.write(taskAppend); fw.close(); } + + private static void restoreOneTask(Scanner key) throws IOException, DukeException, IndexOutOfBoundsException{ + String line = key.nextLine(); + line = removeNumberAndDot(line).trim(); //each line looks like [T][ ] Description + boolean isDone = line.charAt(4) == 'X'; + String description = line.substring(7); + + switch (line.charAt(1)) { + case 'T': + String todoCmd = "todo " + "description"; + Duke.list[Duke.taskCount] = Todo.newTodoTask(todoCmd); + if (isDone){ + Duke.list[Duke.taskCount].restoreIsDone(); + } + Duke.taskCount++; + Text.restoreTaskIntoFile(); + break; + + case 'D': + //3.[D][ ] return book (by: Friday) + String due = ddlExtract(description); + String ddltask = description.substring(0, description.indexOf("(by: ") - 2); + String ddlCmd = "deadline " + ddltask + " /by " + due; + Duke.list[Duke.taskCount] = task.Deadline.newDdl(ddlCmd); + if (isDone){ + Duke.list[Duke.taskCount].restoreIsDone(); + } + Duke.taskCount++; + Text.restoreTaskIntoFile(); + break; + + case 'E': + //4.[E][ ] java lesson (from: Friday 4pm to: 6pm) + //event java lesson /from Friday 4pm /to 6pm + String eventCmd = getEventCmd(description); + Duke.list[Duke.taskCount] = task.Deadline.newDdl(eventCmd); + if (isDone){ + Duke.list[Duke.taskCount].restoreIsDone(); + } + Duke.taskCount++; + Text.restoreTaskIntoFile(); + break; + } + } + + private static String getEventCmd(String description) throws IndexOutOfBoundsException{ + int indexOfFrom = description.indexOf("(from"); + int indexOfTo = description.indexOf("to:"); + String start = description.substring(indexOfFrom + 7, indexOfTo).trim(); + String end = description.substring(indexOfTo + 4); + String eventTask = description.substring(0, indexOfFrom); + return "event " + eventTask + " /from " + start + " /to " + end; + } + + private static String removeNumberAndDot(String input) { + // Replace the number and dot at the beginning of the line with an empty string + return input.replaceFirst("^\\d+\\.\\s*", ""); + } + + private static String ddlExtract(String description) { + int startIndex = description.indexOf("(by: ") + 5; + int endIndex = description.indexOf(")"); + return description.substring(startIndex, endIndex); + } + + public static void restoreSavedData(String DATA_PATH) throws IOException, DukeException, IndexOutOfBoundsException{ + try { + File file = new File(DATA_PATH); + Scanner scan = new Scanner(file); + while (scan.hasNext()) { + restoreOneTask(scan); + } + } catch (IndexOutOfBoundsException ofb) { + System.out.println("Failed to load the saved file. Please check if your backup is in the correct format."); + System.out.println("We will start with a new empty file."); + clearData(); + } + } } diff --git a/src/main/java/message/text.java b/src/main/java/message/Text.java similarity index 92% rename from src/main/java/message/text.java rename to src/main/java/message/Text.java index 486b5ad42..d5e660adb 100644 --- a/src/main/java/message/text.java +++ b/src/main/java/message/Text.java @@ -8,7 +8,7 @@ import static duke.Duke.list; import static duke.Duke.taskCount; -public class text { +public class Text { public static void printWelcomeMessage() { System.out.println("Hello! I'm Oriento."); @@ -46,12 +46,6 @@ public static void printList() throws IOException{ } printFileContents("data/taskList.txt"); - // This is to print the whole task message directly - /* - for (int i = 0; i < count; i++) { - //example 1.[T][X] read book - System.out.println((i + 1) + "." + list[i]); - }*/ } public static void createTaskSuccessMsg() throws IOException{ @@ -64,6 +58,11 @@ public static void createTaskSuccessMsg() throws IOException{ writeToFile("data/taskList.txt", taskAppend); } + public static void restoreTaskIntoFile() throws IOException { + String taskAppend = taskCount + ". " + list[taskCount - 1].toString() + "\n"; + writeToFile("data/taskList.txt", taskAppend); + } + private static void writeToFile(String filePath, String taskAppend) throws IOException { FileWriter fw = new FileWriter(filePath, true); fw.write(taskAppend); diff --git a/src/main/java/task/Deadline.java b/src/main/java/task/Deadline.java index 50e8b72f1..157be2814 100644 --- a/src/main/java/task/Deadline.java +++ b/src/main/java/task/Deadline.java @@ -1,7 +1,11 @@ package task; +import commandFormat.TimeParser; import exception.DukeException; +import java.sql.Time; +import java.time.LocalDateTime; + public class Deadline extends Task { protected String due; @@ -16,16 +20,18 @@ public static Deadline newDdl(String userCommand) throws DukeException { if (!(userCommand.contains("/by"))){ throw new DukeException("Oh, no! I cannot detect the keyword '/by' "); } + userCommand = userCommand.substring(9); + int indexOfBy = userCommand.indexOf("/by"); + String ddlTask = userCommand.substring(0, indexOfBy).trim(); + String due = userCommand.substring(indexOfBy + 4); - String[] ddlSplit = userCommand.split("/"); - int spaceIndex = ddlSplit[0].indexOf(" "); - String ddlTask = ddlSplit[0].substring(spaceIndex + 1).trim(); - - return new Deadline(ddlTask, ddlSplit[1].substring(3)); + return new Deadline(ddlTask, due); } @Override public String toString() { - return "[D]" + super.toString() + " (by: " + this.due + ")"; + LocalDateTime time = TimeParser.parseDateTime(this.due); + String dueTime = TimeParser.convertDateTimetoString(time); + return "[D]" + super.toString() + " (by: " + dueTime + ")"; } } diff --git a/src/main/java/task/Event.java b/src/main/java/task/Event.java index 68fb2e4bf..606079f43 100644 --- a/src/main/java/task/Event.java +++ b/src/main/java/task/Event.java @@ -1,7 +1,10 @@ package task; +import commandFormat.TimeParser; import exception.DukeException; +import java.time.LocalDateTime; + public class Event extends Task { protected String start, end; @@ -16,11 +19,12 @@ public static Event newEventTask(String userCommand) throws DukeException { if (!(userCommand.contains("/from")) || !(userCommand.contains("/to"))){ throw new DukeException("Oh, no! There is no '/from' or '/to' "); } - String[] eventSplit = userCommand.split("/"); - int spaceIndex = eventSplit[0].indexOf(" "); - String eventTask = eventSplit[0].substring(spaceIndex + 1).trim(); - String start = eventSplit[1].trim().substring(5); // Remove "/from " prefix - String end = eventSplit[2].trim().substring(3); // Remove "/to " prefix + userCommand = userCommand.substring(6); //remove "event" + int indexOfFrom = userCommand.indexOf("/from"); + int indexOfTo = userCommand.indexOf("/to"); + String start = userCommand.substring(indexOfFrom + 6, indexOfTo).trim(); + String end = userCommand.substring(indexOfTo + 4).trim(); + String eventTask = userCommand.substring(0, indexOfFrom).trim(); return new Event(eventTask, start, end); } @@ -28,6 +32,7 @@ public static Event newEventTask(String userCommand) throws DukeException { @Override public String toString() { //print example: [E][ ] project meeting (from: Aug 6th 2pm to: 4pm) + return "[E]" + super.toString() + " (from: " + this.start + " to: " + this.end + ")"; } diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java index a2c6541f6..e4989d23d 100644 --- a/src/main/java/task/Task.java +++ b/src/main/java/task/Task.java @@ -28,6 +28,10 @@ public void setDone(int taskNo, int taskCount, Task[] list) { } } + public void restoreIsDone(){ + this.isDone = true; + } + public void setNotDone(int taskNo, int taskCount, Task[] list) { if ( (taskNo > taskCount ) || (taskNo <1) ){ System.out.println("Oops! You don't have any task in this position."); From 73a6403df7e5e54e77658e14042b8029aaec5529 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 6 Oct 2023 21:19:09 +0800 Subject: [PATCH 27/86] correct bugs on time praser --- data/taskList.txt | 3 +++ src/main/java/task/Deadline.java | 10 +++++++--- src/main/java/task/Event.java | 11 +++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/data/taskList.txt b/data/taskList.txt index e69de29bb..9ee492e00 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -0,0 +1,3 @@ +1. [E][ ] read book (from: 2月 12 2019 06:00 下午 to: 2月 12 2019 07:00 下午) +2. [E][ ] read book (from: 2/12/2019 1800 to: 2/12/2019) +3. [E][ ] read book (from: 2/12 1800 to: 2/12/2019) diff --git a/src/main/java/task/Deadline.java b/src/main/java/task/Deadline.java index 157be2814..73d362bc1 100644 --- a/src/main/java/task/Deadline.java +++ b/src/main/java/task/Deadline.java @@ -30,8 +30,12 @@ public static Deadline newDdl(String userCommand) throws DukeException { @Override public String toString() { - LocalDateTime time = TimeParser.parseDateTime(this.due); - String dueTime = TimeParser.convertDateTimetoString(time); - return "[D]" + super.toString() + " (by: " + dueTime + ")"; + try { + LocalDateTime time = TimeParser.parseDateTime(this.due); + String dueTime = TimeParser.convertDateTimetoString(time); + return "[D]" + super.toString() + " (by: " + dueTime + ")"; + } catch (Exception e) { + return "[D]" + super.toString() + " (by: " + this.due + ")"; + } } } diff --git a/src/main/java/task/Event.java b/src/main/java/task/Event.java index 606079f43..564cd798a 100644 --- a/src/main/java/task/Event.java +++ b/src/main/java/task/Event.java @@ -32,8 +32,15 @@ public static Event newEventTask(String userCommand) throws DukeException { @Override public String toString() { //print example: [E][ ] project meeting (from: Aug 6th 2pm to: 4pm) - - return "[E]" + super.toString() + " (from: " + this.start + " to: " + this.end + ")"; + try { + LocalDateTime tmp = TimeParser.parseDateTime(this.start); + String startTime = TimeParser.convertDateTimetoString(tmp); + tmp = TimeParser.parseDateTime(this.end); + String endTime = TimeParser.convertDateTimetoString(tmp); + return "[E]" + super.toString() + " (from: " + startTime + " to: " + endTime + ")"; + } catch (Exception e) { + return "[E]" + super.toString() + " (from: " + this.start + " to: " + this.end + ")"; + } } } From 851801ed8d7250f2615ef225ba5b0bfc9242dbb4 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 6 Oct 2023 22:44:00 +0800 Subject: [PATCH 28/86] add find functionality --- data/taskList.txt | 6 ++-- src/main/java/command/DeadlineCommand.java | 3 ++ src/main/java/command/EventCommand.java | 3 ++ src/main/java/command/FindCommand.java | 36 +++++++++++++++++++ src/main/java/command/MarkCommand.java | 9 ++++- src/main/java/command/UnmarkCommand.java | 7 ++++ src/main/java/commandFormat/CommandType.java | 3 ++ src/main/java/duke/Duke.java | 2 +- .../java/exception/InvalidTimeException.java | 8 +++++ src/main/java/fileIO/FileIO.java | 6 ++-- src/main/java/task/Deadline.java | 22 ++++++++++-- src/main/java/task/Event.java | 22 +++++++++++- src/main/java/task/Task.java | 4 +++ 13 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 src/main/java/command/FindCommand.java create mode 100644 src/main/java/exception/InvalidTimeException.java diff --git a/data/taskList.txt b/data/taskList.txt index 9ee492e00..fc2fb1b7b 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1,3 +1,3 @@ -1. [E][ ] read book (from: 2月 12 2019 06:00 下午 to: 2月 12 2019 07:00 下午) -2. [E][ ] read book (from: 2/12/2019 1800 to: 2/12/2019) -3. [E][ ] read book (from: 2/12 1800 to: 2/12/2019) +1. [T][ ] read book +2. [T][ ] read book 2 +3. [D][ ] read book (by: friday) diff --git a/src/main/java/command/DeadlineCommand.java b/src/main/java/command/DeadlineCommand.java index 391e32d76..e987dda3c 100644 --- a/src/main/java/command/DeadlineCommand.java +++ b/src/main/java/command/DeadlineCommand.java @@ -2,6 +2,7 @@ import duke.Duke; import exception.DukeException; +import exception.InvalidTimeException; import message.Text; import task.Deadline; @@ -22,6 +23,8 @@ public void executeCommand(){ e.incorrectFormatException("deadline"); } catch (IOException io){ System.out.println("OMG! Something went wrong! Please check if the source files are available."); + } catch (InvalidTimeException ite){ + System.out.println("Please check your schedule."); } } diff --git a/src/main/java/command/EventCommand.java b/src/main/java/command/EventCommand.java index ef660ade5..ab4418d9f 100644 --- a/src/main/java/command/EventCommand.java +++ b/src/main/java/command/EventCommand.java @@ -2,6 +2,7 @@ import duke.Duke; import exception.DukeException; +import exception.InvalidTimeException; import message.Text; import task.Event; @@ -22,6 +23,8 @@ public void executeCommand(){ e.incorrectFormatException("event"); } catch (IOException io){ System.out.println("OMG! Something went wrong! Please check if the source files are available."); + } catch (InvalidTimeException d){ + System.out.println("Please check your period again."); } } diff --git a/src/main/java/command/FindCommand.java b/src/main/java/command/FindCommand.java new file mode 100644 index 000000000..07abfec3e --- /dev/null +++ b/src/main/java/command/FindCommand.java @@ -0,0 +1,36 @@ +package command; + +import duke.Duke; + +public class FindCommand extends Command { + private String keyword; + + public FindCommand(String keyword){ + super(false); + this.keyword = keyword; + } + + private String findResult() { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < Duke.taskCount; i++) { + if(Duke.list[i].getDescription().contains(this.keyword)) { + String taskAppend = (i +1) + ". " + Duke.list[i].toString(); + sb.append(taskAppend).append("\n"); + } + } + return sb.toString(); + } + + + @Override + public void executeCommand() { + if(! this.findResult().isEmpty()){ + System.out.println("Great! I have find some similar result for you."); + System.out.println(this.findResult()); + } else { + System.out.println("I am sorry but I cannot find any result for you..."); + } + + } + +} diff --git a/src/main/java/command/MarkCommand.java b/src/main/java/command/MarkCommand.java index c8bb149ef..35ef48b6a 100644 --- a/src/main/java/command/MarkCommand.java +++ b/src/main/java/command/MarkCommand.java @@ -1,8 +1,12 @@ package command; import duke.Duke; +import task.Task; + +import java.io.IOException; import static commandFormat.CommandFormat.getTaskNo; +import static fileIO.FileIO.overwriteToFile; public class MarkCommand extends Command { @@ -14,12 +18,15 @@ public MarkCommand(String index) { } @Override - public void executeCommand() { + public void executeCommand(){ try { int taskNo = getTaskNo(this.index); Duke.list[taskNo - 1].setDone(taskNo, Duke.taskCount, Duke.list); + overwriteToFile("data/taskList.txt", Task.getConcatenateTasks()); } catch (NumberFormatException nfe) { System.out.println("Hey, please input your command with the correct task number."); + } catch (IOException e) { + System.out.println("Oh NO! Failed to find save file!"); } } diff --git a/src/main/java/command/UnmarkCommand.java b/src/main/java/command/UnmarkCommand.java index 4cadf3cd1..bc09f92e3 100644 --- a/src/main/java/command/UnmarkCommand.java +++ b/src/main/java/command/UnmarkCommand.java @@ -1,8 +1,12 @@ package command; import duke.Duke; +import task.Task; + +import java.io.IOException; import static commandFormat.CommandFormat.getTaskNo; +import static fileIO.FileIO.overwriteToFile; public class UnmarkCommand extends Command{ @@ -18,8 +22,11 @@ public void executeCommand() { try { int taskNo = getTaskNo(this.index); Duke.list[taskNo - 1].setNotDone(taskNo, Duke.taskCount, Duke.list); + overwriteToFile("data/taskList.txt", Task.getConcatenateTasks()); } catch (NumberFormatException nfe) { System.out.println("Hey, please input your command with the correct task number."); + } catch (IOException e) { + System.out.println("Oh NO! Failed to find save file!"); } } } diff --git a/src/main/java/commandFormat/CommandType.java b/src/main/java/commandFormat/CommandType.java index 1ae3c2fc1..59a25f997 100644 --- a/src/main/java/commandFormat/CommandType.java +++ b/src/main/java/commandFormat/CommandType.java @@ -23,6 +23,9 @@ public static Command parseCommand(String input) throws DukeException { case "event": command = new EventCommand(input); break; + case "find": + command = new FindCommand(commandSplits[1]); + break; case "mark": command = new MarkCommand(commandSplits[1]); break; diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 98b82f3e7..0a596164b 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -4,6 +4,7 @@ import command.Command; import commandFormat.CommandFormat; import commandFormat.CommandType; + import task.*; import message.Text; @@ -12,7 +13,6 @@ import java.io.IOException; import java.util.Scanner; - import fileIO.FileIO; diff --git a/src/main/java/exception/InvalidTimeException.java b/src/main/java/exception/InvalidTimeException.java new file mode 100644 index 000000000..a87602e1a --- /dev/null +++ b/src/main/java/exception/InvalidTimeException.java @@ -0,0 +1,8 @@ +package exception; + +public class InvalidTimeException extends Exception { + + public InvalidTimeException(String message) { + super(message); + } +} diff --git a/src/main/java/fileIO/FileIO.java b/src/main/java/fileIO/FileIO.java index 23a2ecfd7..677063c95 100644 --- a/src/main/java/fileIO/FileIO.java +++ b/src/main/java/fileIO/FileIO.java @@ -2,6 +2,7 @@ import duke.Duke; import exception.DukeException; +import exception.InvalidTimeException; import task.Todo; import message.Text; @@ -78,7 +79,8 @@ public static void overwriteToFile(String filePath, String taskAppend) throws IO fw.close(); } - private static void restoreOneTask(Scanner key) throws IOException, DukeException, IndexOutOfBoundsException{ + private static void restoreOneTask(Scanner key) throws IOException, DukeException, IndexOutOfBoundsException, + InvalidTimeException { String line = key.nextLine(); line = removeNumberAndDot(line).trim(); //each line looks like [T][ ] Description boolean isDone = line.charAt(4) == 'X'; @@ -149,7 +151,7 @@ public static void restoreSavedData(String DATA_PATH) throws IOException, DukeEx while (scan.hasNext()) { restoreOneTask(scan); } - } catch (IndexOutOfBoundsException ofb) { + } catch (IndexOutOfBoundsException | InvalidTimeException ofb) { System.out.println("Failed to load the saved file. Please check if your backup is in the correct format."); System.out.println("We will start with a new empty file."); clearData(); diff --git a/src/main/java/task/Deadline.java b/src/main/java/task/Deadline.java index 73d362bc1..92d336a91 100644 --- a/src/main/java/task/Deadline.java +++ b/src/main/java/task/Deadline.java @@ -2,9 +2,11 @@ import commandFormat.TimeParser; import exception.DukeException; +import exception.InvalidTimeException; -import java.sql.Time; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.format.DateTimeParseException; public class Deadline extends Task { @@ -15,7 +17,14 @@ public Deadline(String description, String due) { this.due = due; } - public static Deadline newDdl(String userCommand) throws DukeException { + /** + * + * @param userCommand Whole userInput start from "deadline" + * @return Deadline object + * @throws DukeException Raises exception if invalid due time while able to parse the input time + * If failed to parse the time, just assume valid input + */ + public static Deadline newDdl(String userCommand) throws DukeException, InvalidTimeException { // command format: deadline return book /by Sunday if (!(userCommand.contains("/by"))){ throw new DukeException("Oh, no! I cannot detect the keyword '/by' "); @@ -25,6 +34,15 @@ public static Deadline newDdl(String userCommand) throws DukeException { String ddlTask = userCommand.substring(0, indexOfBy).trim(); String due = userCommand.substring(indexOfBy + 4); + try{ + LocalDateTime dueTime = TimeParser.parseDateTime(due); + LocalDateTime now = LocalDateTime.now(); + if (dueTime.isBefore(now)) { + throw new InvalidTimeException("Invalid Time! Deadline is over already!"); + } + } catch (DateTimeParseException d){ + /* do nothing */ + } return new Deadline(ddlTask, due); } diff --git a/src/main/java/task/Event.java b/src/main/java/task/Event.java index 564cd798a..b56d3cbbd 100644 --- a/src/main/java/task/Event.java +++ b/src/main/java/task/Event.java @@ -2,8 +2,10 @@ import commandFormat.TimeParser; import exception.DukeException; +import exception.InvalidTimeException; import java.time.LocalDateTime; +import java.time.format.DateTimeParseException; public class Event extends Task { protected String start, end; @@ -14,7 +16,7 @@ public Event(String description, String start, String end) { this.end = end; } - public static Event newEventTask(String userCommand) throws DukeException { + public static Event newEventTask(String userCommand) throws DukeException, InvalidTimeException { //command format: event project meeting /from Mon 2pm /to 4pm if (!(userCommand.contains("/from")) || !(userCommand.contains("/to"))){ throw new DukeException("Oh, no! There is no '/from' or '/to' "); @@ -25,9 +27,27 @@ public static Event newEventTask(String userCommand) throws DukeException { String start = userCommand.substring(indexOfFrom + 6, indexOfTo).trim(); String end = userCommand.substring(indexOfTo + 4).trim(); String eventTask = userCommand.substring(0, indexOfFrom).trim(); + testTimeInput(start, end); + return new Event(eventTask, start, end); } + private static void testTimeInput(String startTime, String endTime) throws InvalidTimeException { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime start = TimeParser.parseDateTime(startTime); + LocalDateTime end = TimeParser.parseDateTime(endTime); + try{ + if(end.isBefore(now)){ + new InvalidTimeException("The event is ended. Please check the end time again."); + } + if(end.isBefore(start)){ + new InvalidTimeException("End time is early than start time."); + } + } catch(DateTimeParseException d) { + /* do nothing */ + } + } + @Override public String toString() { diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java index e4989d23d..6cd2ccd4d 100644 --- a/src/main/java/task/Task.java +++ b/src/main/java/task/Task.java @@ -63,6 +63,10 @@ public static String getConcatenateTasks() { return stringBuilder.toString(); } + public String getDescription() { + return description; + } + @Override public String toString() { return "[" + this.getStatusIcon() + "] " + this.description; From 156c911888585a9cdae5b13d371dfa63fdff62f9 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 6 Oct 2023 23:31:37 +0800 Subject: [PATCH 29/86] add more decumentations --- src/main/java/command/AddCommand.java | 3 ++ src/main/java/command/ByeCommand.java | 6 +-- src/main/java/command/Command.java | 11 +++++- src/main/java/command/DeadlineCommand.java | 5 ++- src/main/java/command/DeleteCommand.java | 8 ++++ src/main/java/command/EventCommand.java | 3 ++ src/main/java/command/FindCommand.java | 4 ++ src/main/java/command/ListCommand.java | 3 ++ src/main/java/command/MarkCommand.java | 7 ++++ src/main/java/command/TodoCommand.java | 5 ++- src/main/java/command/UnmarkCommand.java | 4 +- .../java/commandFormat/CommandFormat.java | 19 +++++++--- src/main/java/commandFormat/TimeParser.java | 11 +++++- src/main/java/duke/Duke.java | 4 +- src/main/java/exception/DukeException.java | 4 -- src/main/java/fileIO/FileIO.java | 37 ++++++++++++++----- src/main/java/message/Text.java | 3 ++ 17 files changed, 109 insertions(+), 28 deletions(-) diff --git a/src/main/java/command/AddCommand.java b/src/main/java/command/AddCommand.java index 7feef828a..5d9af21de 100644 --- a/src/main/java/command/AddCommand.java +++ b/src/main/java/command/AddCommand.java @@ -1,5 +1,8 @@ package command; +/** + * general command features with user raw command and + */ public abstract class AddCommand extends Command { protected String command; diff --git a/src/main/java/command/ByeCommand.java b/src/main/java/command/ByeCommand.java index e6a4d7870..b53a68b17 100644 --- a/src/main/java/command/ByeCommand.java +++ b/src/main/java/command/ByeCommand.java @@ -7,16 +7,16 @@ public class ByeCommand extends Command { - + /** + * only bye message will change isExit field to true + */ public ByeCommand() { super(true); } @Override public void executeCommand() { - Text.printByeMessage(); FileIO.backupTaskFile(); - } } diff --git a/src/main/java/command/Command.java b/src/main/java/command/Command.java index f589c65c5..783a8a753 100644 --- a/src/main/java/command/Command.java +++ b/src/main/java/command/Command.java @@ -1,8 +1,13 @@ package command; import java.io.IOException; - +/** + * parent class representing all user instructions + */ public abstract class Command { + /** + * use isExit to keep tract if the user want to quit + */ private boolean isExit; public Command(boolean isExit){ @@ -13,6 +18,10 @@ public boolean isExit(){ return isExit; } + /** + * + * @throws IOException file input output error in case file cannot be found + */ public abstract void executeCommand() throws IOException; } diff --git a/src/main/java/command/DeadlineCommand.java b/src/main/java/command/DeadlineCommand.java index e987dda3c..888ff7b9a 100644 --- a/src/main/java/command/DeadlineCommand.java +++ b/src/main/java/command/DeadlineCommand.java @@ -9,7 +9,10 @@ import java.io.IOException; public class DeadlineCommand extends AddCommand { - + /** + * + * @param ddlCmd deadline command represents the original command starts from "deadline" + */ public DeadlineCommand(String ddlCmd){ super(ddlCmd); } diff --git a/src/main/java/command/DeleteCommand.java b/src/main/java/command/DeleteCommand.java index 73245c6d1..ecc1c3c68 100644 --- a/src/main/java/command/DeleteCommand.java +++ b/src/main/java/command/DeleteCommand.java @@ -19,6 +19,10 @@ public DeleteCommand(String index) { this.index = index; } + /** + * delete command uses to delete a task at particular index i, i>0 + * @throws IOException raises error if fail to delete task from current file + */ @Override public void executeCommand() throws IOException { try { @@ -29,6 +33,10 @@ public void executeCommand() throws IOException { } } + /** + * + * the taskCount is updated in the method deleteTaskSuccessMsg + */ private static void deleteTask(int deleteIndex) throws IOException{ if (deleteIndex <= 0 || deleteIndex> Duke.taskCount){ System.out.println("Oh, No! invalid index! You don't have that task. Please try again."); diff --git a/src/main/java/command/EventCommand.java b/src/main/java/command/EventCommand.java index ab4418d9f..bf557160d 100644 --- a/src/main/java/command/EventCommand.java +++ b/src/main/java/command/EventCommand.java @@ -14,6 +14,9 @@ public EventCommand(String eventTask){ super(eventTask); } + /** + * eventTask represent the whole original user command starts from "event" + */ @Override public void executeCommand(){ try { diff --git a/src/main/java/command/FindCommand.java b/src/main/java/command/FindCommand.java index 07abfec3e..d00a86428 100644 --- a/src/main/java/command/FindCommand.java +++ b/src/main/java/command/FindCommand.java @@ -10,6 +10,10 @@ public FindCommand(String keyword){ this.keyword = keyword; } + /** + * the find method implement by comparing all the task descriptions with the keyword + * @return string containing all lines of results found + */ private String findResult() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < Duke.taskCount; i++) { diff --git a/src/main/java/command/ListCommand.java b/src/main/java/command/ListCommand.java index 4ae5ee843..86ca59673 100644 --- a/src/main/java/command/ListCommand.java +++ b/src/main/java/command/ListCommand.java @@ -10,6 +10,9 @@ public ListCommand(){ super(false); } + /** + * list out all the tasks by print out all content in the saved file + */ @Override public void executeCommand() { try { diff --git a/src/main/java/command/MarkCommand.java b/src/main/java/command/MarkCommand.java index 35ef48b6a..6946f4d8d 100644 --- a/src/main/java/command/MarkCommand.java +++ b/src/main/java/command/MarkCommand.java @@ -12,11 +12,18 @@ public class MarkCommand extends Command { private String index; + /** + * + * @param index points to the target task + */ public MarkCommand(String index) { super(false); this.index = index; } + /** + * overwriteFile update the whole saved file with updated content, i.e. one task marked + */ @Override public void executeCommand(){ try { diff --git a/src/main/java/command/TodoCommand.java b/src/main/java/command/TodoCommand.java index 65cc7e02e..9d1fde1f8 100644 --- a/src/main/java/command/TodoCommand.java +++ b/src/main/java/command/TodoCommand.java @@ -8,7 +8,10 @@ import java.io.IOException; public class TodoCommand extends AddCommand{ - + /** + * + * @param todoCmd represents thw whole original user command starts from "todo“ + */ public TodoCommand(String todoCmd){ super(todoCmd); } diff --git a/src/main/java/command/UnmarkCommand.java b/src/main/java/command/UnmarkCommand.java index bc09f92e3..2e56a8ca1 100644 --- a/src/main/java/command/UnmarkCommand.java +++ b/src/main/java/command/UnmarkCommand.java @@ -9,7 +9,9 @@ import static fileIO.FileIO.overwriteToFile; public class UnmarkCommand extends Command{ - + /** + * similar to mark + */ private String index; public UnmarkCommand(String index) { diff --git a/src/main/java/commandFormat/CommandFormat.java b/src/main/java/commandFormat/CommandFormat.java index e143c9d69..039d8d45d 100644 --- a/src/main/java/commandFormat/CommandFormat.java +++ b/src/main/java/commandFormat/CommandFormat.java @@ -2,20 +2,29 @@ public class CommandFormat { - + /** + * transform to smaller letter, removing leading and ending space, and contract any consecutive space + * @param cmd user command + * @return updated command + */ public static String formattedCommand(String cmd){ - cmd = cmd.trim().toLowerCase(); //small letter and remove front and back space - cmd = cmd.replaceAll("\\s+", " "); //remove if consecutive space + cmd = cmd.trim().toLowerCase(); + cmd = cmd.replaceAll("\\s+", " "); return cmd; } + /** + * gives exception when taskNum is not number, or containing non-numerical value + */ public static int getTaskNo(String taskNum) { - //exception: taskNum is not number, or containing non-numerical value return Integer.parseInt(taskNum); } - //To tackle cases of invalid input like 'todo', 'event', etc. + /** + * use to tackle valid starting input like "todo", "event", "list", + * but lacking in index or having extra index + */ public static boolean missingOrExtraTaskDescription(String[] cmd){ if (cmd.length == 1){ if(cmd[0].equals("todo") || cmd[0].equals("event") || cmd[0].equals("deadline") diff --git a/src/main/java/commandFormat/TimeParser.java b/src/main/java/commandFormat/TimeParser.java index 0e0bc49c2..5acf3fb25 100644 --- a/src/main/java/commandFormat/TimeParser.java +++ b/src/main/java/commandFormat/TimeParser.java @@ -6,12 +6,21 @@ import java.util.Locale; public class TimeParser { - + /** + * + * @param input time string + * @return LocalDataTIme object + */ public static LocalDateTime parseDateTime(String input) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy Hmm"); return LocalDateTime.parse(input, formatter); } + /** + * + * @param dateTime object of LocalDateTime + * @return converted string + */ public static String convertDateTimetoString(LocalDateTime dateTime) { return dateTime.format(DateTimeFormatter.ofPattern("MMM d yyyy hh:mm a")); } diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 0a596164b..3d719ee23 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -15,7 +15,9 @@ import java.util.Scanner; import fileIO.FileIO; - +/** + * Starting point of program + */ public class Duke { public static int taskCount = 0; diff --git a/src/main/java/exception/DukeException.java b/src/main/java/exception/DukeException.java index 9f3bd1b40..d7c681ba4 100644 --- a/src/main/java/exception/DukeException.java +++ b/src/main/java/exception/DukeException.java @@ -33,11 +33,7 @@ public void incorrectFormatException(String taskType) { System.out.println("Example: event project meeting /from Mon 2pm /to 4pm"); break; - case "delete": - break; - default: - //for case without correct start and empty command System.out.println("Please start with the supported task types: 'todo', 'deadline', 'event'. "); } diff --git a/src/main/java/fileIO/FileIO.java b/src/main/java/fileIO/FileIO.java index 677063c95..7cb9fa707 100644 --- a/src/main/java/fileIO/FileIO.java +++ b/src/main/java/fileIO/FileIO.java @@ -9,24 +9,29 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.nio.file.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.nio.file.StandardCopyOption; -import java.time.LocalDateTime; import java.util.Scanner; public class FileIO { - + /** + * This method check if target repository and input,output files is found + * if not, create the file for users + * if error occurs in restoring data, e.g. the saved content contains invalid contents, + * clear All the data and starts with a empty file + * @throws IOException once cannot access file or file not found + * @throws DukeException from method restoreSavedData + */ public static void outputFileInitialization() throws IOException, DukeException { checkAndCreateDataFolder(); checkAndCreateFile("data\\taskList.txt"); checkAndCreateFile("data/backup_taskList.txt"); - clearData(); //if the output file in not empty + clearData(); restoreSavedData("data/backup_taskList.txt"); } @@ -48,10 +53,10 @@ private static void checkAndCreateDataFolder() throws IOException { } } + /** + * save the file when exit the program + */ public static void backupTaskFile() { - // Path sourcePath = Paths.get("data/taskList.txt"); - //Path targetPath = Paths.get("data/backup_taskList.txt"); - // Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); //if file not exist, create one; try { File src = new File("data\\taskList.txt"); File dst = new File("data\\backup_taskList.txt"); @@ -79,9 +84,15 @@ public static void overwriteToFile(String filePath, String taskAppend) throws IO fw.close(); } - private static void restoreOneTask(Scanner key) throws IOException, DukeException, IndexOutOfBoundsException, + /** + * + * this method aims to restore all saved data from backup file once start the program + * it implements by forming old user command for creating tasks, + * and generate the task list using the command one by one + */ + private static void restoreOneTask(Scanner keyboard) throws IOException, DukeException, IndexOutOfBoundsException, InvalidTimeException { - String line = key.nextLine(); + String line = keyboard.nextLine(); line = removeNumberAndDot(line).trim(); //each line looks like [T][ ] Description boolean isDone = line.charAt(4) == 'X'; String description = line.substring(7); @@ -124,6 +135,10 @@ private static void restoreOneTask(Scanner key) throws IOException, DukeExceptio } } + /** + * + * helper function to generate the old user input based on saved file + */ private static String getEventCmd(String description) throws IndexOutOfBoundsException{ int indexOfFrom = description.indexOf("(from"); int indexOfTo = description.indexOf("to:"); @@ -134,10 +149,12 @@ private static String getEventCmd(String description) throws IndexOutOfBoundsExc } private static String removeNumberAndDot(String input) { - // Replace the number and dot at the beginning of the line with an empty string return input.replaceFirst("^\\d+\\.\\s*", ""); } + /** + * helper function to extract deadline task descriptions from user input + */ private static String ddlExtract(String description) { int startIndex = description.indexOf("(by: ") + 5; int endIndex = description.indexOf(")"); diff --git a/src/main/java/message/Text.java b/src/main/java/message/Text.java index d5e660adb..e5f943c58 100644 --- a/src/main/java/message/Text.java +++ b/src/main/java/message/Text.java @@ -9,6 +9,9 @@ import static duke.Duke.taskCount; public class Text { + /** + * this class contains all user + */ public static void printWelcomeMessage() { System.out.println("Hello! I'm Oriento."); From 00c05b92daf92aaf3d40a72c91598d03e459873c Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Fri, 6 Oct 2023 23:47:25 +0800 Subject: [PATCH 30/86] add more documentations --- src/main/java/message/Text.java | 2 +- src/main/java/task/Deadline.java | 5 +++++ src/main/java/task/Event.java | 12 ++++++++++-- src/main/java/task/Task.java | 11 +++++++++-- src/main/java/task/Todo.java | 5 ++++- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/java/message/Text.java b/src/main/java/message/Text.java index e5f943c58..c98517288 100644 --- a/src/main/java/message/Text.java +++ b/src/main/java/message/Text.java @@ -10,7 +10,7 @@ public class Text { /** - * this class contains all user + * this class contains all user interacting messages */ public static void printWelcomeMessage() { diff --git a/src/main/java/task/Deadline.java b/src/main/java/task/Deadline.java index 92d336a91..2ef0bfa88 100644 --- a/src/main/java/task/Deadline.java +++ b/src/main/java/task/Deadline.java @@ -46,6 +46,11 @@ public static Deadline newDdl(String userCommand) throws DukeException, InvalidT return new Deadline(ddlTask, due); } + /** + * print example: [D][ ] return book (by: Friday) + * if failed to parse input time, assume user input is valid + * @return string of task message + */ @Override public String toString() { try { diff --git a/src/main/java/task/Event.java b/src/main/java/task/Event.java index b56d3cbbd..e8cf677c3 100644 --- a/src/main/java/task/Event.java +++ b/src/main/java/task/Event.java @@ -16,6 +16,12 @@ public Event(String description, String start, String end) { this.end = end; } + /** + * extreact start and end from userCommand first + * then test if the input is valid + * if failed to parse input, assume the user is true + * @InvalidTimeException caught in EventCommand class + */ public static Event newEventTask(String userCommand) throws DukeException, InvalidTimeException { //command format: event project meeting /from Mon 2pm /to 4pm if (!(userCommand.contains("/from")) || !(userCommand.contains("/to"))){ @@ -48,10 +54,12 @@ private static void testTimeInput(String startTime, String endTime) throws Inval } } - + /** + * print example: [E][ ] project meeting (from: Aug 6th 2pm to: 4pm) + * @return string containing event task information + */ @Override public String toString() { - //print example: [E][ ] project meeting (from: Aug 6th 2pm to: 4pm) try { LocalDateTime tmp = TimeParser.parseDateTime(this.start); String startTime = TimeParser.convertDateTimetoString(tmp); diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java index 6cd2ccd4d..d9b222798 100644 --- a/src/main/java/task/Task.java +++ b/src/main/java/task/Task.java @@ -44,7 +44,11 @@ public void setNotDone(int taskNo, int taskCount, Task[] list) { } } - //return a new list after delete the target object + /** + * only use to update list array once an objected is deleted and removed + * @param indexOfDelete target index + * @return a new list object array + */ public static Task[] updatedTaskList(int indexOfDelete){ Task[] newList = new Task[100]; int numOfCopy = Duke.list.length - indexOfDelete - 1; @@ -53,7 +57,10 @@ public static Task[] updatedTaskList(int indexOfDelete){ return newList; } - //This method will return all tasks inside the list + /** + * + * @return string contains all task data + */ public static String getConcatenateTasks() { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < Duke.taskCount; i++) { diff --git a/src/main/java/task/Todo.java b/src/main/java/task/Todo.java index 4aad0841d..2fd64ef16 100644 --- a/src/main/java/task/Todo.java +++ b/src/main/java/task/Todo.java @@ -16,7 +16,10 @@ public static Todo newTodoTask(String userCommand) throws DukeException { return new Todo(todoSplit[1]); } - + /** + * print example: [T][ ] read book + * @return string contains todo task information + */ @Override public String toString() { return "[T]" + super.toString() ; From 2c00b17f004a0fd9554a61b761cf3a2daacd5526 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sun, 8 Oct 2023 02:05:53 +0800 Subject: [PATCH 31/86] launch jar --- data/backup_taskList.txt | 5 ++ data/taskList.txt | 8 +-- src/main/java/META-INF/MANIFEST.MF | 3 ++ .../{duke/Duke.java => Oriento/Oriento.java} | 11 ++-- src/main/java/command/DeadlineCommand.java | 8 +-- src/main/java/command/DeleteCommand.java | 6 +-- src/main/java/command/EventCommand.java | 8 +-- src/main/java/command/FindCommand.java | 8 +-- src/main/java/command/HelpCommand.java | 17 ++++++ src/main/java/command/MarkCommand.java | 4 +- src/main/java/command/TodoCommand.java | 8 +-- src/main/java/command/UnmarkCommand.java | 4 +- src/main/java/commandFormat/CommandType.java | 9 ++-- ...keException.java => OrientoException.java} | 6 +-- src/main/java/fileIO/FileIO.java | 52 +++++++++---------- src/main/java/message/Text.java | 28 +++++----- src/main/java/task/Deadline.java | 17 +++--- src/main/java/task/Event.java | 19 ++++--- src/main/java/task/Task.java | 12 ++--- src/main/java/task/Todo.java | 6 +-- 20 files changed, 140 insertions(+), 99 deletions(-) create mode 100644 src/main/java/META-INF/MANIFEST.MF rename src/main/java/{duke/Duke.java => Oriento/Oriento.java} (88%) create mode 100644 src/main/java/command/HelpCommand.java rename src/main/java/exception/{DukeException.java => OrientoException.java} (90%) diff --git a/data/backup_taskList.txt b/data/backup_taskList.txt index e69de29bb..9231f4dee 100644 --- a/data/backup_taskList.txt +++ b/data/backup_taskList.txt @@ -0,0 +1,5 @@ +1. [T][ ] 1 +2. [T][ ] 2 +3. [T][ ] 1 +4. [E][ ] okkk (from: mon to: /ood) +5. [D][ ] asw (by: mon) diff --git a/data/taskList.txt b/data/taskList.txt index fc2fb1b7b..ff51541c9 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1,3 +1,5 @@ -1. [T][ ] read book -2. [T][ ] read book 2 -3. [D][ ] read book (by: friday) +1. [T][ ] 1 +2. [T][ ] 2 +3. [T][ ] 1 +4. [E][ ] okkk (from: mon to: /ood)) +5. [D][ ] asw (by: mon) diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 000000000..2ce16c054 --- /dev/null +++ b/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: Oriento.Oriento + diff --git a/src/main/java/duke/Duke.java b/src/main/java/Oriento/Oriento.java similarity index 88% rename from src/main/java/duke/Duke.java rename to src/main/java/Oriento/Oriento.java index 3d719ee23..0feb13426 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/Oriento/Oriento.java @@ -1,4 +1,4 @@ -package duke; +package Oriento; import command.Command; @@ -8,7 +8,7 @@ import task.*; import message.Text; -import exception.DukeException; +import exception.OrientoException; import java.io.FileNotFoundException; import java.io.IOException; @@ -18,12 +18,12 @@ /** * Starting point of program */ -public class Duke { +public class Oriento { public static int taskCount = 0; public static Task[] list = new Task[100]; - public static void main(String[] args) throws IOException, DukeException { + public static void main(String[] args) throws IOException, OrientoException { Text.printWelcomeMessage(); Scanner keyboard = new Scanner(System.in); FileIO.outputFileInitialization(); @@ -45,11 +45,12 @@ private static void executeCommand(Scanner keyboard) { Command command = CommandType.parseCommand(cmd); command.executeCommand(); isExit = command.isExit(); + Text.printdottedline(); } catch (NumberFormatException nfe) { System.out.println("Hey, please input your command with the correct task number."); } catch (NullPointerException npe){ System.out.println("Your target task doesn't exist. Please input a correct task."); - } catch (DukeException e){ + } catch (OrientoException e){ e.incorrectFormatException(commandSplits[0]); } catch (FileNotFoundException fnf){ System.out.println("Sorry, I cannot find the task source. Please check the task file."); diff --git a/src/main/java/command/DeadlineCommand.java b/src/main/java/command/DeadlineCommand.java index 888ff7b9a..415e68ffd 100644 --- a/src/main/java/command/DeadlineCommand.java +++ b/src/main/java/command/DeadlineCommand.java @@ -1,7 +1,7 @@ package command; -import duke.Duke; -import exception.DukeException; +import Oriento.Oriento; +import exception.OrientoException; import exception.InvalidTimeException; import message.Text; import task.Deadline; @@ -20,9 +20,9 @@ public DeadlineCommand(String ddlCmd){ @Override public void executeCommand(){ try { - Duke.list[Duke.taskCount] = Deadline.newDdl(this.command); + Oriento.list[Oriento.taskCount] = Deadline.newDdl(this.command); Text.createTaskSuccessMsg(); - } catch (DukeException e) { + } catch (OrientoException e) { e.incorrectFormatException("deadline"); } catch (IOException io){ System.out.println("OMG! Something went wrong! Please check if the source files are available."); diff --git a/src/main/java/command/DeleteCommand.java b/src/main/java/command/DeleteCommand.java index ecc1c3c68..0a8b1fc03 100644 --- a/src/main/java/command/DeleteCommand.java +++ b/src/main/java/command/DeleteCommand.java @@ -1,6 +1,6 @@ package command; -import duke.Duke; +import Oriento.Oriento; import message.Text; import task.Task; @@ -38,12 +38,12 @@ public void executeCommand() throws IOException { * the taskCount is updated in the method deleteTaskSuccessMsg */ private static void deleteTask(int deleteIndex) throws IOException{ - if (deleteIndex <= 0 || deleteIndex> Duke.taskCount){ + if (deleteIndex <= 0 || deleteIndex> Oriento.taskCount){ System.out.println("Oh, No! invalid index! You don't have that task. Please try again."); return; } Text.deleteTaskSuccessMsg(deleteIndex); - Duke.list = Task.updatedTaskList(deleteIndex - 1); + Oriento.list = Task.updatedTaskList(deleteIndex - 1); overwriteToFile("data/taskList.txt", Task.getConcatenateTasks()); } diff --git a/src/main/java/command/EventCommand.java b/src/main/java/command/EventCommand.java index bf557160d..157c58dc8 100644 --- a/src/main/java/command/EventCommand.java +++ b/src/main/java/command/EventCommand.java @@ -1,7 +1,7 @@ package command; -import duke.Duke; -import exception.DukeException; +import Oriento.Oriento; +import exception.OrientoException; import exception.InvalidTimeException; import message.Text; import task.Event; @@ -20,9 +20,9 @@ public EventCommand(String eventTask){ @Override public void executeCommand(){ try { - Duke.list[Duke.taskCount] = Event.newEventTask(this.command); + Oriento.list[Oriento.taskCount] = Event.newEventTask(this.command); Text.createTaskSuccessMsg(); - } catch (DukeException e) { + } catch (OrientoException e) { e.incorrectFormatException("event"); } catch (IOException io){ System.out.println("OMG! Something went wrong! Please check if the source files are available."); diff --git a/src/main/java/command/FindCommand.java b/src/main/java/command/FindCommand.java index d00a86428..e04526f52 100644 --- a/src/main/java/command/FindCommand.java +++ b/src/main/java/command/FindCommand.java @@ -1,6 +1,6 @@ package command; -import duke.Duke; +import Oriento.Oriento; public class FindCommand extends Command { private String keyword; @@ -16,9 +16,9 @@ public FindCommand(String keyword){ */ private String findResult() { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < Duke.taskCount; i++) { - if(Duke.list[i].getDescription().contains(this.keyword)) { - String taskAppend = (i +1) + ". " + Duke.list[i].toString(); + for (int i = 0; i < Oriento.taskCount; i++) { + if(Oriento.list[i].getDescription().contains(this.keyword)) { + String taskAppend = (i +1) + ". " + Oriento.list[i].toString(); sb.append(taskAppend).append("\n"); } } diff --git a/src/main/java/command/HelpCommand.java b/src/main/java/command/HelpCommand.java new file mode 100644 index 000000000..0c57a6c9e --- /dev/null +++ b/src/main/java/command/HelpCommand.java @@ -0,0 +1,17 @@ +package command; + +import message.Text; + + +public class HelpCommand extends Command { + + public HelpCommand(){ + super(false); + } + + @Override + public void executeCommand() { + Text.printHelpMessage(); + } + +} diff --git a/src/main/java/command/MarkCommand.java b/src/main/java/command/MarkCommand.java index 6946f4d8d..eb1022d42 100644 --- a/src/main/java/command/MarkCommand.java +++ b/src/main/java/command/MarkCommand.java @@ -1,6 +1,6 @@ package command; -import duke.Duke; +import Oriento.Oriento; import task.Task; import java.io.IOException; @@ -28,7 +28,7 @@ public MarkCommand(String index) { public void executeCommand(){ try { int taskNo = getTaskNo(this.index); - Duke.list[taskNo - 1].setDone(taskNo, Duke.taskCount, Duke.list); + Oriento.list[taskNo - 1].setDone(taskNo, Oriento.taskCount, Oriento.list); overwriteToFile("data/taskList.txt", Task.getConcatenateTasks()); } catch (NumberFormatException nfe) { System.out.println("Hey, please input your command with the correct task number."); diff --git a/src/main/java/command/TodoCommand.java b/src/main/java/command/TodoCommand.java index 9d1fde1f8..3898f217b 100644 --- a/src/main/java/command/TodoCommand.java +++ b/src/main/java/command/TodoCommand.java @@ -1,7 +1,7 @@ package command; -import duke.Duke; -import exception.DukeException; +import Oriento.Oriento; +import exception.OrientoException; import message.Text; import task.Todo; @@ -19,9 +19,9 @@ public TodoCommand(String todoCmd){ @Override public void executeCommand(){ try { - Duke.list[Duke.taskCount] = Todo.newTodoTask(this.command); + Oriento.list[Oriento.taskCount] = Todo.newTodoTask(this.command); Text.createTaskSuccessMsg(); - } catch (DukeException e) { + } catch (OrientoException e) { e.incorrectFormatException("todo"); } catch (IOException io){ System.out.println("OMG! Something went wrong! Please check if the source files are available."); diff --git a/src/main/java/command/UnmarkCommand.java b/src/main/java/command/UnmarkCommand.java index 2e56a8ca1..1eb86fe8f 100644 --- a/src/main/java/command/UnmarkCommand.java +++ b/src/main/java/command/UnmarkCommand.java @@ -1,6 +1,6 @@ package command; -import duke.Duke; +import Oriento.Oriento; import task.Task; import java.io.IOException; @@ -23,7 +23,7 @@ public UnmarkCommand(String index) { public void executeCommand() { try { int taskNo = getTaskNo(this.index); - Duke.list[taskNo - 1].setNotDone(taskNo, Duke.taskCount, Duke.list); + Oriento.list[taskNo - 1].setNotDone(taskNo, Oriento.taskCount, Oriento.list); overwriteToFile("data/taskList.txt", Task.getConcatenateTasks()); } catch (NumberFormatException nfe) { System.out.println("Hey, please input your command with the correct task number."); diff --git a/src/main/java/commandFormat/CommandType.java b/src/main/java/commandFormat/CommandType.java index 59a25f997..e032ea039 100644 --- a/src/main/java/commandFormat/CommandType.java +++ b/src/main/java/commandFormat/CommandType.java @@ -1,11 +1,11 @@ package commandFormat; import command.*; -import exception.DukeException; +import exception.OrientoException; public class CommandType { - public static Command parseCommand(String input) throws DukeException { + public static Command parseCommand(String input) throws OrientoException { String[] commandSplits = input.split(" "); Command command; @@ -38,8 +38,11 @@ public static Command parseCommand(String input) throws DukeException { case "bye": command = new ByeCommand(); break; + case "help": + command = new HelpCommand(); + break; default: - throw new DukeException(); + throw new OrientoException(); } return command; diff --git a/src/main/java/exception/DukeException.java b/src/main/java/exception/OrientoException.java similarity index 90% rename from src/main/java/exception/DukeException.java rename to src/main/java/exception/OrientoException.java index d7c681ba4..10e04a5e4 100644 --- a/src/main/java/exception/DukeException.java +++ b/src/main/java/exception/OrientoException.java @@ -1,11 +1,11 @@ package exception; -public class DukeException extends Exception { +public class OrientoException extends Exception { - public DukeException() { + public OrientoException() { } - public DukeException(String message) { + public OrientoException(String message) { super(message); } diff --git a/src/main/java/fileIO/FileIO.java b/src/main/java/fileIO/FileIO.java index 7cb9fa707..acd1538df 100644 --- a/src/main/java/fileIO/FileIO.java +++ b/src/main/java/fileIO/FileIO.java @@ -1,8 +1,9 @@ package fileIO; -import duke.Duke; -import exception.DukeException; +import Oriento.Oriento; +import exception.OrientoException; import exception.InvalidTimeException; +import task.Task; import task.Todo; import message.Text; @@ -25,9 +26,9 @@ public class FileIO { * if error occurs in restoring data, e.g. the saved content contains invalid contents, * clear All the data and starts with a empty file * @throws IOException once cannot access file or file not found - * @throws DukeException from method restoreSavedData + * @throws OrientoException from method restoreSavedData */ - public static void outputFileInitialization() throws IOException, DukeException { + public static void outputFileInitialization() throws IOException, OrientoException { checkAndCreateDataFolder(); checkAndCreateFile("data\\taskList.txt"); checkAndCreateFile("data/backup_taskList.txt"); @@ -58,24 +59,21 @@ private static void checkAndCreateDataFolder() throws IOException { */ public static void backupTaskFile() { try { - File src = new File("data\\taskList.txt"); - File dst = new File("data\\backup_taskList.txt"); - copyFile(src, dst); - System.out.println("Great! I have saved the current tasks."); + String currentContent = Task.getConcatenateTasks(); + overwriteToFile("data\\backup_taskList.txt", currentContent); } catch (IOException e) { System.out.println("Oh No! I cannot save the file. Please check if the backup file is available."); } } - private static void copyFile(File source, File dest) throws IOException { - Files.copy(source.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); - } - private static void clearData() throws IOException { Path clearFile = Paths.get("data/taskList.txt"); if (Files.size(clearFile) != 0) { Files.write(clearFile, new byte[0], StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); } + Task[] emptylist = new Task[100]; + Oriento.list = emptylist; + Oriento.taskCount = 0; } public static void overwriteToFile(String filePath, String taskAppend) throws IOException { @@ -90,34 +88,35 @@ public static void overwriteToFile(String filePath, String taskAppend) throws IO * it implements by forming old user command for creating tasks, * and generate the task list using the command one by one */ - private static void restoreOneTask(Scanner keyboard) throws IOException, DukeException, IndexOutOfBoundsException, + private static void restoreOneTask(Scanner keyboard) throws IOException, OrientoException, IndexOutOfBoundsException, InvalidTimeException { String line = keyboard.nextLine(); line = removeNumberAndDot(line).trim(); //each line looks like [T][ ] Description boolean isDone = line.charAt(4) == 'X'; - String description = line.substring(7); + String description = line.substring(7); //remove brackets [T][ ] switch (line.charAt(1)) { case 'T': - String todoCmd = "todo " + "description"; - Duke.list[Duke.taskCount] = Todo.newTodoTask(todoCmd); + String todoCmd = "todo " + description; + Oriento.list[Oriento.taskCount] = Todo.newTodoTask(todoCmd); if (isDone){ - Duke.list[Duke.taskCount].restoreIsDone(); + Oriento.list[Oriento.taskCount].restoreIsDone(); } - Duke.taskCount++; + Oriento.taskCount++; Text.restoreTaskIntoFile(); break; case 'D': //3.[D][ ] return book (by: Friday) + //asw (by: mon) String due = ddlExtract(description); - String ddltask = description.substring(0, description.indexOf("(by: ") - 2); + String ddltask = description.substring(0, description.indexOf("(by: ")).trim(); String ddlCmd = "deadline " + ddltask + " /by " + due; - Duke.list[Duke.taskCount] = task.Deadline.newDdl(ddlCmd); + Oriento.list[Oriento.taskCount] = task.Deadline.newDdl(ddlCmd); if (isDone){ - Duke.list[Duke.taskCount].restoreIsDone(); + Oriento.list[Oriento.taskCount].restoreIsDone(); } - Duke.taskCount++; + Oriento.taskCount++; Text.restoreTaskIntoFile(); break; @@ -125,11 +124,11 @@ private static void restoreOneTask(Scanner keyboard) throws IOException, DukeExc //4.[E][ ] java lesson (from: Friday 4pm to: 6pm) //event java lesson /from Friday 4pm /to 6pm String eventCmd = getEventCmd(description); - Duke.list[Duke.taskCount] = task.Deadline.newDdl(eventCmd); + Oriento.list[Oriento.taskCount] = task.Event.newEventTask(eventCmd); if (isDone){ - Duke.list[Duke.taskCount].restoreIsDone(); + Oriento.list[Oriento.taskCount].restoreIsDone(); } - Duke.taskCount++; + Oriento.taskCount++; Text.restoreTaskIntoFile(); break; } @@ -154,6 +153,7 @@ private static String removeNumberAndDot(String input) { /** * helper function to extract deadline task descriptions from user input + * expected input format: 5. [D][ ] asw (by: mon) */ private static String ddlExtract(String description) { int startIndex = description.indexOf("(by: ") + 5; @@ -161,7 +161,7 @@ private static String ddlExtract(String description) { return description.substring(startIndex, endIndex); } - public static void restoreSavedData(String DATA_PATH) throws IOException, DukeException, IndexOutOfBoundsException{ + public static void restoreSavedData(String DATA_PATH) throws IOException, OrientoException, IndexOutOfBoundsException{ try { File file = new File(DATA_PATH); Scanner scan = new Scanner(file); diff --git a/src/main/java/message/Text.java b/src/main/java/message/Text.java index c98517288..87cbfe2e8 100644 --- a/src/main/java/message/Text.java +++ b/src/main/java/message/Text.java @@ -5,8 +5,8 @@ import java.io.IOException; import java.util.Scanner; -import static duke.Duke.list; -import static duke.Duke.taskCount; +import static Oriento.Oriento.list; +import static Oriento.Oriento.taskCount; public class Text { /** @@ -16,18 +16,14 @@ public class Text { public static void printWelcomeMessage() { System.out.println("Hello! I'm Oriento."); System.out.println("What can I help you?"); - System.out.println("⣿⣿⣿⠟⠛⠛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢋⣩⣉⢻⣿\n" + - "⣿⣿⣿⠀⣿⣶⣕⣈⠹⠿⠿⠿⠿⠟⠛⣛⢋⣰⠣⣿⣿⠀⣿⣿\n" + - "⣿⣿⣿⡀⣿⣿⣿⣧⢻⣿⣶⣷⣿⣿⣿⣿⣿⣿⠿⠶⡝⠀⣿⣿\n" + - "⣿⣿⣿⣷⠘⣿⣿⣿⢏⣿⣿⣋⣀⣈⣻⣿⣿⣷⣤⣤⣿⡐⢿⣿\n" + - "⣿⣿⣿⣿⣆⢩⣝⣫⣾⣿⣿⣿⣿⡟⠿⠿⠦⠀⠸⠿⣻⣿⡄⢻⣿\n" + - "⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⠇⣼⣿\n" + - "⣿⣿⣿⣿⣿⣿⡄⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣰⣿\n" + - "⣿⣿⣿⣿⣿⣿⠇⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣿⣿\n" + - "⣿⣿⣿⣿⣿⠏⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢸⣿⣿\n" + - "⣿⣿⣿⣿⠟⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⣿⣿\n" + - "⣿⣿⣿⠋⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⣿⣿\n" + - "⣿⣿⠋⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿\n"); + } + + public static void printHelpMessage() { + System.out.println("Sorry I do not tell you use how to give commands. Please see the following hints."); + System.out.println("Hint1: To create a task, please start with 'todo', 'event', 'deadline'."); + System.out.println("Hint2: To modify task statue, please start with 'mark' or 'unmark'."); + System.out.println("please use 'list' to look for your task list, or 'delete' to remove a task."); + System.out.println("You may use 'find' to search for your task."); } public static void printByeMessage(){ @@ -79,4 +75,8 @@ public static void deleteTaskSuccessMsg(int deleteIndex) { System.out.println("Now you have " + taskCount + " tasks in the list."); } + public static void printdottedline() { + System.out.println("================================================"); + } + } diff --git a/src/main/java/task/Deadline.java b/src/main/java/task/Deadline.java index 2ef0bfa88..a0b0787ce 100644 --- a/src/main/java/task/Deadline.java +++ b/src/main/java/task/Deadline.java @@ -1,10 +1,9 @@ package task; import commandFormat.TimeParser; -import exception.DukeException; +import exception.OrientoException; import exception.InvalidTimeException; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeParseException; @@ -21,15 +20,20 @@ public Deadline(String description, String due) { * * @param userCommand Whole userInput start from "deadline" * @return Deadline object - * @throws DukeException Raises exception if invalid due time while able to parse the input time + * @throws OrientoException Raises exception if invalid due time while able to parse the input time * If failed to parse the time, just assume valid input */ - public static Deadline newDdl(String userCommand) throws DukeException, InvalidTimeException { + public static Deadline newDdl(String userCommand) throws OrientoException, InvalidTimeException { // command format: deadline return book /by Sunday if (!(userCommand.contains("/by"))){ - throw new DukeException("Oh, no! I cannot detect the keyword '/by' "); + throw new OrientoException("Oh, no! I cannot detect the keyword '/by' "); } - userCommand = userCommand.substring(9); + userCommand = userCommand.substring(9); //remove "deadline" + + if(userCommand.startsWith("/by")){ + throw new OrientoException("Cannot find deadline description. Please try again."); + } + int indexOfBy = userCommand.indexOf("/by"); String ddlTask = userCommand.substring(0, indexOfBy).trim(); String due = userCommand.substring(indexOfBy + 4); @@ -46,6 +50,7 @@ public static Deadline newDdl(String userCommand) throws DukeException, InvalidT return new Deadline(ddlTask, due); } + /** * print example: [D][ ] return book (by: Friday) * if failed to parse input time, assume user input is valid diff --git a/src/main/java/task/Event.java b/src/main/java/task/Event.java index e8cf677c3..5212ddd75 100644 --- a/src/main/java/task/Event.java +++ b/src/main/java/task/Event.java @@ -1,7 +1,7 @@ package task; import commandFormat.TimeParser; -import exception.DukeException; +import exception.OrientoException; import exception.InvalidTimeException; import java.time.LocalDateTime; @@ -22,12 +22,17 @@ public Event(String description, String start, String end) { * if failed to parse input, assume the user is true * @InvalidTimeException caught in EventCommand class */ - public static Event newEventTask(String userCommand) throws DukeException, InvalidTimeException { + public static Event newEventTask(String userCommand) throws OrientoException, InvalidTimeException { //command format: event project meeting /from Mon 2pm /to 4pm if (!(userCommand.contains("/from")) || !(userCommand.contains("/to"))){ - throw new DukeException("Oh, no! There is no '/from' or '/to' "); + throw new OrientoException("Oh, no! There is no '/from' or '/to' "); } userCommand = userCommand.substring(6); //remove "event" + + if(userCommand.startsWith("/from")){ + throw new OrientoException("Cannot find event description. Please try again."); + } + int indexOfFrom = userCommand.indexOf("/from"); int indexOfTo = userCommand.indexOf("/to"); String start = userCommand.substring(indexOfFrom + 6, indexOfTo).trim(); @@ -40,14 +45,14 @@ public static Event newEventTask(String userCommand) throws DukeException, Inval private static void testTimeInput(String startTime, String endTime) throws InvalidTimeException { LocalDateTime now = LocalDateTime.now(); - LocalDateTime start = TimeParser.parseDateTime(startTime); - LocalDateTime end = TimeParser.parseDateTime(endTime); try{ + LocalDateTime start = TimeParser.parseDateTime(startTime); + LocalDateTime end = TimeParser.parseDateTime(endTime); if(end.isBefore(now)){ - new InvalidTimeException("The event is ended. Please check the end time again."); + throw new InvalidTimeException("The event is ended. Please check the end time again."); } if(end.isBefore(start)){ - new InvalidTimeException("End time is early than start time."); + throw new InvalidTimeException("End time is early than start time."); } } catch(DateTimeParseException d) { /* do nothing */ diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java index d9b222798..d3412802d 100644 --- a/src/main/java/task/Task.java +++ b/src/main/java/task/Task.java @@ -1,6 +1,6 @@ package task; -import duke.Duke; +import Oriento.Oriento; public class Task { @@ -51,9 +51,9 @@ public void setNotDone(int taskNo, int taskCount, Task[] list) { */ public static Task[] updatedTaskList(int indexOfDelete){ Task[] newList = new Task[100]; - int numOfCopy = Duke.list.length - indexOfDelete - 1; - System.arraycopy(Duke.list, 0, newList, 0, indexOfDelete); - System.arraycopy(Duke.list, indexOfDelete + 1, newList, indexOfDelete, numOfCopy); + int numOfCopy = Oriento.list.length - indexOfDelete - 1; + System.arraycopy(Oriento.list, 0, newList, 0, indexOfDelete); + System.arraycopy(Oriento.list, indexOfDelete + 1, newList, indexOfDelete, numOfCopy); return newList; } @@ -63,8 +63,8 @@ public static Task[] updatedTaskList(int indexOfDelete){ */ public static String getConcatenateTasks() { StringBuilder stringBuilder = new StringBuilder(); - for (int i = 0; i < Duke.taskCount; i++) { - String taskAppend = (i +1) + ". " + Duke.list[i].toString(); + for (int i = 0; i < Oriento.taskCount; i++) { + String taskAppend = (i +1) + ". " + Oriento.list[i].toString(); stringBuilder.append(taskAppend).append("\n"); } return stringBuilder.toString(); diff --git a/src/main/java/task/Todo.java b/src/main/java/task/Todo.java index 2fd64ef16..c025ba7f4 100644 --- a/src/main/java/task/Todo.java +++ b/src/main/java/task/Todo.java @@ -1,6 +1,6 @@ package task; -import exception.DukeException; +import exception.OrientoException; public class Todo extends Task { @@ -8,10 +8,10 @@ public Todo(String description) { super(description); } - public static Todo newTodoTask(String userCommand) throws DukeException { + public static Todo newTodoTask(String userCommand) throws OrientoException { String[] todoSplit = userCommand.split(" ", 2); if ( todoSplit[1].isEmpty() ){ - throw new DukeException("You got nothing to create. Please try again."); + throw new OrientoException("You got nothing to create. Please try again."); } return new Todo(todoSplit[1]); } From 85b7029adb446ca06e4cd3423412b99b763bb193 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sun, 8 Oct 2023 03:30:45 +0800 Subject: [PATCH 32/86] correct some bugs --- data/backup_taskList.txt | 12 ++-- data/taskList.txt | 12 ++-- src/main/java/Oriento/Oriento.java | 1 + src/main/java/command/ByeCommand.java | 1 - src/main/java/fileIO/FileIO.java | 88 ++++++++++++++------------- 5 files changed, 60 insertions(+), 54 deletions(-) diff --git a/data/backup_taskList.txt b/data/backup_taskList.txt index 9231f4dee..fc6080882 100644 --- a/data/backup_taskList.txt +++ b/data/backup_taskList.txt @@ -1,5 +1,7 @@ -1. [T][ ] 1 -2. [T][ ] 2 -3. [T][ ] 1 -4. [E][ ] okkk (from: mon to: /ood) -5. [D][ ] asw (by: mon) +1. [T][ ] 2 +2. [T][ ] 1 +3. [E][ ] okkk (from: mon to: /ood) +4. [T][ ] 1 +5. [T][ ] 1 +6. [T][ ] 2 +7. [E][ ] ioss (from: monday to: tue) diff --git a/data/taskList.txt b/data/taskList.txt index ff51541c9..fc6080882 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1,5 +1,7 @@ -1. [T][ ] 1 -2. [T][ ] 2 -3. [T][ ] 1 -4. [E][ ] okkk (from: mon to: /ood)) -5. [D][ ] asw (by: mon) +1. [T][ ] 2 +2. [T][ ] 1 +3. [E][ ] okkk (from: mon to: /ood) +4. [T][ ] 1 +5. [T][ ] 1 +6. [T][ ] 2 +7. [E][ ] ioss (from: monday to: tue) diff --git a/src/main/java/Oriento/Oriento.java b/src/main/java/Oriento/Oriento.java index 0feb13426..14a47f52d 100644 --- a/src/main/java/Oriento/Oriento.java +++ b/src/main/java/Oriento/Oriento.java @@ -45,6 +45,7 @@ private static void executeCommand(Scanner keyboard) { Command command = CommandType.parseCommand(cmd); command.executeCommand(); isExit = command.isExit(); + FileIO.backupTaskFile(); Text.printdottedline(); } catch (NumberFormatException nfe) { System.out.println("Hey, please input your command with the correct task number."); diff --git a/src/main/java/command/ByeCommand.java b/src/main/java/command/ByeCommand.java index b53a68b17..b168dac56 100644 --- a/src/main/java/command/ByeCommand.java +++ b/src/main/java/command/ByeCommand.java @@ -17,6 +17,5 @@ public ByeCommand() { @Override public void executeCommand() { Text.printByeMessage(); - FileIO.backupTaskFile(); } } diff --git a/src/main/java/fileIO/FileIO.java b/src/main/java/fileIO/FileIO.java index acd1538df..d5b3ba25a 100644 --- a/src/main/java/fileIO/FileIO.java +++ b/src/main/java/fileIO/FileIO.java @@ -15,7 +15,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; -import java.nio.file.StandardCopyOption; import java.util.Scanner; @@ -28,12 +27,18 @@ public class FileIO { * @throws IOException once cannot access file or file not found * @throws OrientoException from method restoreSavedData */ - public static void outputFileInitialization() throws IOException, OrientoException { + public static void outputFileInitialization() throws IOException { checkAndCreateDataFolder(); checkAndCreateFile("data\\taskList.txt"); checkAndCreateFile("data/backup_taskList.txt"); clearData(); - restoreSavedData("data/backup_taskList.txt"); + try{ + restoreSavedData("data/backup_taskList.txt"); + } catch (Exception e){ + System.out.println("Failed to load the saved file. Please check if your backup is in the correct format."); + System.out.println("We will start with a new empty file."); + clearData(); + } } private static void checkAndCreateFile(String path) throws IOException { @@ -88,50 +93,46 @@ public static void overwriteToFile(String filePath, String taskAppend) throws IO * it implements by forming old user command for creating tasks, * and generate the task list using the command one by one */ - private static void restoreOneTask(Scanner keyboard) throws IOException, OrientoException, IndexOutOfBoundsException, - InvalidTimeException { + private static void restoreOneTask(Scanner keyboard) throws IndexOutOfBoundsException, + InvalidTimeException, OrientoException, IOException { String line = keyboard.nextLine(); line = removeNumberAndDot(line).trim(); //each line looks like [T][ ] Description boolean isDone = line.charAt(4) == 'X'; String description = line.substring(7); //remove brackets [T][ ] - - switch (line.charAt(1)) { - case 'T': - String todoCmd = "todo " + description; - Oriento.list[Oriento.taskCount] = Todo.newTodoTask(todoCmd); - if (isDone){ - Oriento.list[Oriento.taskCount].restoreIsDone(); - } - Oriento.taskCount++; - Text.restoreTaskIntoFile(); - break; - - case 'D': - //3.[D][ ] return book (by: Friday) - //asw (by: mon) - String due = ddlExtract(description); - String ddltask = description.substring(0, description.indexOf("(by: ")).trim(); - String ddlCmd = "deadline " + ddltask + " /by " + due; - Oriento.list[Oriento.taskCount] = task.Deadline.newDdl(ddlCmd); - if (isDone){ - Oriento.list[Oriento.taskCount].restoreIsDone(); + switch (line.charAt(1)) { + case 'T': + String todoCmd = "todo " + description; + Oriento.list[Oriento.taskCount] = Todo.newTodoTask(todoCmd); + if (isDone){ + Oriento.list[Oriento.taskCount].restoreIsDone(); + } + Oriento.taskCount++; + Text.restoreTaskIntoFile(); + break; + + case 'D': + //3.[D][ ] return book (by: Friday) + String due = ddlExtract(description); + String ddltask = description.substring(0, description.indexOf("(by: ")).trim(); + String ddlCmd = "deadline " + ddltask + " /by " + due; + Oriento.list[Oriento.taskCount] = task.Deadline.newDdl(ddlCmd); + if (isDone){ + Oriento.list[Oriento.taskCount].restoreIsDone(); + } + Oriento.taskCount++; + Text.restoreTaskIntoFile(); + break; + + case 'E': + String eventCmd = getEventCmd(description); + Oriento.list[Oriento.taskCount] = task.Event.newEventTask(eventCmd); + if (isDone){ + Oriento.list[Oriento.taskCount].restoreIsDone(); + } + Oriento.taskCount++; + Text.restoreTaskIntoFile(); + break; } - Oriento.taskCount++; - Text.restoreTaskIntoFile(); - break; - - case 'E': - //4.[E][ ] java lesson (from: Friday 4pm to: 6pm) - //event java lesson /from Friday 4pm /to 6pm - String eventCmd = getEventCmd(description); - Oriento.list[Oriento.taskCount] = task.Event.newEventTask(eventCmd); - if (isDone){ - Oriento.list[Oriento.taskCount].restoreIsDone(); - } - Oriento.taskCount++; - Text.restoreTaskIntoFile(); - break; - } } /** @@ -141,8 +142,9 @@ private static void restoreOneTask(Scanner keyboard) throws IOException, Oriento private static String getEventCmd(String description) throws IndexOutOfBoundsException{ int indexOfFrom = description.indexOf("(from"); int indexOfTo = description.indexOf("to:"); + int indexOfEnd = description.indexOf(")"); String start = description.substring(indexOfFrom + 7, indexOfTo).trim(); - String end = description.substring(indexOfTo + 4); + String end = description.substring(indexOfTo + 4, indexOfEnd); String eventTask = description.substring(0, indexOfFrom); return "event " + eventTask + " /from " + start + " /to " + end; } From efa64fe86bfba0cb7ec976e1448c103b2e585282 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sun, 8 Oct 2023 10:41:26 +0800 Subject: [PATCH 33/86] correct some issues on running the program over Linux system --- data/backup_taskList.txt | 9 ++------- data/taskList.txt | 9 ++------- src/main/java/fileIO/FileIO.java | 4 ++-- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/data/backup_taskList.txt b/data/backup_taskList.txt index fc6080882..adeb3f1ba 100644 --- a/data/backup_taskList.txt +++ b/data/backup_taskList.txt @@ -1,7 +1,2 @@ -1. [T][ ] 2 -2. [T][ ] 1 -3. [E][ ] okkk (from: mon to: /ood) -4. [T][ ] 1 -5. [T][ ] 1 -6. [T][ ] 2 -7. [E][ ] ioss (from: monday to: tue) +1. [T][ ] ok +2. [T][ ] this is 2 diff --git a/data/taskList.txt b/data/taskList.txt index fc6080882..adeb3f1ba 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1,7 +1,2 @@ -1. [T][ ] 2 -2. [T][ ] 1 -3. [E][ ] okkk (from: mon to: /ood) -4. [T][ ] 1 -5. [T][ ] 1 -6. [T][ ] 2 -7. [E][ ] ioss (from: monday to: tue) +1. [T][ ] ok +2. [T][ ] this is 2 diff --git a/src/main/java/fileIO/FileIO.java b/src/main/java/fileIO/FileIO.java index d5b3ba25a..eec22a895 100644 --- a/src/main/java/fileIO/FileIO.java +++ b/src/main/java/fileIO/FileIO.java @@ -29,7 +29,7 @@ public class FileIO { */ public static void outputFileInitialization() throws IOException { checkAndCreateDataFolder(); - checkAndCreateFile("data\\taskList.txt"); + checkAndCreateFile("data/taskList.txt"); checkAndCreateFile("data/backup_taskList.txt"); clearData(); try{ @@ -65,7 +65,7 @@ private static void checkAndCreateDataFolder() throws IOException { public static void backupTaskFile() { try { String currentContent = Task.getConcatenateTasks(); - overwriteToFile("data\\backup_taskList.txt", currentContent); + overwriteToFile("data/backup_taskList.txt", currentContent); } catch (IOException e) { System.out.println("Oh No! I cannot save the file. Please check if the backup file is available."); } From da1aa7c4d566675387716ae12dbde82fb48f9bdb Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sat, 21 Oct 2023 16:57:24 +0800 Subject: [PATCH 34/86] Add more documentation --- src/main/java/Oriento/Oriento.java | 4 ++++ src/main/java/command/AddCommand.java | 4 ++++ src/main/java/command/ByeCommand.java | 6 +++++- src/main/java/command/Command.java | 2 ++ src/main/java/command/DeadlineCommand.java | 11 ++++++++-- src/main/java/command/DeleteCommand.java | 2 +- src/main/java/command/EventCommand.java | 6 +++++- src/main/java/command/FindCommand.java | 5 ++++- src/main/java/command/HelpCommand.java | 3 +++ src/main/java/command/ListCommand.java | 1 + src/main/java/command/MarkCommand.java | 3 ++- src/main/java/command/TodoCommand.java | 4 ++++ src/main/java/command/UnmarkCommand.java | 4 ++++ .../java/commandFormat/CommandFormat.java | 4 ++-- src/main/java/commandFormat/CommandType.java | 6 ++++++ src/main/java/exception/OrientoException.java | 5 +++++ src/main/java/fileIO/FileIO.java | 21 ++++++++++++++++++- src/main/java/message/Text.java | 13 ++++++++++++ src/main/java/task/Event.java | 8 +++++++ src/main/java/task/Task.java | 9 ++++++++ 20 files changed, 111 insertions(+), 10 deletions(-) diff --git a/src/main/java/Oriento/Oriento.java b/src/main/java/Oriento/Oriento.java index 14a47f52d..d3d03797d 100644 --- a/src/main/java/Oriento/Oriento.java +++ b/src/main/java/Oriento/Oriento.java @@ -30,6 +30,10 @@ public static void main(String[] args) throws IOException, OrientoException { executeCommand(keyboard); } + /** + * this method will loop until user type in exit command + * @param keyboard represents user input source + */ private static void executeCommand(Scanner keyboard) { boolean isExit = false; diff --git a/src/main/java/command/AddCommand.java b/src/main/java/command/AddCommand.java index 5d9af21de..34c289388 100644 --- a/src/main/java/command/AddCommand.java +++ b/src/main/java/command/AddCommand.java @@ -6,6 +6,10 @@ public abstract class AddCommand extends Command { protected String command; + /** + * initialize the inherited isExit field as false + * @param cmd represents raw user Command + */ public AddCommand(String cmd){ super(false); this.command = cmd; diff --git a/src/main/java/command/ByeCommand.java b/src/main/java/command/ByeCommand.java index b168dac56..aa76aa0fe 100644 --- a/src/main/java/command/ByeCommand.java +++ b/src/main/java/command/ByeCommand.java @@ -7,13 +7,17 @@ public class ByeCommand extends Command { + /** - * only bye message will change isExit field to true + * only bye message can change isExit field to true */ public ByeCommand() { super(true); } + /** + * only print bye message when running bye execution + */ @Override public void executeCommand() { Text.printByeMessage(); diff --git a/src/main/java/command/Command.java b/src/main/java/command/Command.java index 783a8a753..1937c9431 100644 --- a/src/main/java/command/Command.java +++ b/src/main/java/command/Command.java @@ -1,10 +1,12 @@ package command; import java.io.IOException; + /** * parent class representing all user instructions */ public abstract class Command { + /** * use isExit to keep tract if the user want to quit */ diff --git a/src/main/java/command/DeadlineCommand.java b/src/main/java/command/DeadlineCommand.java index 415e68ffd..3d56ba9ba 100644 --- a/src/main/java/command/DeadlineCommand.java +++ b/src/main/java/command/DeadlineCommand.java @@ -9,14 +9,21 @@ import java.io.IOException; public class DeadlineCommand extends AddCommand { + /** - * - * @param ddlCmd deadline command represents the original command starts from "deadline" + * reusing the constructor of AddCommand + * @param ddlCmd represents raw user command starts from "deadline" */ public DeadlineCommand(String ddlCmd){ super(ddlCmd); } + /** + * Exception could occur in the following cases: + * 1. Input deadline command is in wrong format + * 2. Failed to write into output file + * 3. Inappropriate deadline is detected, e.g. deadline is pass already + */ @Override public void executeCommand(){ try { diff --git a/src/main/java/command/DeleteCommand.java b/src/main/java/command/DeleteCommand.java index 0a8b1fc03..a192c9070 100644 --- a/src/main/java/command/DeleteCommand.java +++ b/src/main/java/command/DeleteCommand.java @@ -21,7 +21,7 @@ public DeleteCommand(String index) { /** * delete command uses to delete a task at particular index i, i>0 - * @throws IOException raises error if fail to delete task from current file + * @throws IOException if failed to access file */ @Override public void executeCommand() throws IOException { diff --git a/src/main/java/command/EventCommand.java b/src/main/java/command/EventCommand.java index 157c58dc8..46bed6bbc 100644 --- a/src/main/java/command/EventCommand.java +++ b/src/main/java/command/EventCommand.java @@ -15,7 +15,11 @@ public EventCommand(String eventTask){ } /** - * eventTask represent the whole original user command starts from "event" + * eventTask represent the whole raw user command starts from "event" + * Exception could occur in the following cases: + * 1. Input event command is with wrong format + * 2. Failed to write into the output file + * 3. Inappropriate period is detected, e.g. event period pass already */ @Override public void executeCommand(){ diff --git a/src/main/java/command/FindCommand.java b/src/main/java/command/FindCommand.java index e04526f52..8ab626300 100644 --- a/src/main/java/command/FindCommand.java +++ b/src/main/java/command/FindCommand.java @@ -25,7 +25,10 @@ private String findResult() { return sb.toString(); } - + /** + * The find execution works by simple implementation of + * checking if the description of a task contains the target + */ @Override public void executeCommand() { if(! this.findResult().isEmpty()){ diff --git a/src/main/java/command/HelpCommand.java b/src/main/java/command/HelpCommand.java index 0c57a6c9e..1c401e6fa 100644 --- a/src/main/java/command/HelpCommand.java +++ b/src/main/java/command/HelpCommand.java @@ -9,6 +9,9 @@ public HelpCommand(){ super(false); } + /** + * use to print help message only + */ @Override public void executeCommand() { Text.printHelpMessage(); diff --git a/src/main/java/command/ListCommand.java b/src/main/java/command/ListCommand.java index 86ca59673..72a1b0af6 100644 --- a/src/main/java/command/ListCommand.java +++ b/src/main/java/command/ListCommand.java @@ -12,6 +12,7 @@ public ListCommand(){ /** * list out all the tasks by print out all content in the saved file + * raises exception if failed to access or locate the output file */ @Override public void executeCommand() { diff --git a/src/main/java/command/MarkCommand.java b/src/main/java/command/MarkCommand.java index eb1022d42..bbd77e323 100644 --- a/src/main/java/command/MarkCommand.java +++ b/src/main/java/command/MarkCommand.java @@ -22,7 +22,8 @@ public MarkCommand(String index) { } /** - * overwriteFile update the whole saved file with updated content, i.e. one task marked + * overwriteFile update the whole saved file with updated content, i.e. one task has been marked + * raises exception if input incorrect number, such as in invalid range; or Failed to access output file */ @Override public void executeCommand(){ diff --git a/src/main/java/command/TodoCommand.java b/src/main/java/command/TodoCommand.java index 3898f217b..ec087c633 100644 --- a/src/main/java/command/TodoCommand.java +++ b/src/main/java/command/TodoCommand.java @@ -16,6 +16,10 @@ public TodoCommand(String todoCmd){ super(todoCmd); } + /** + * add a new todo task into the taskList + * raises exception if todo command is in incorrect format or the output file cannot be accessed + */ @Override public void executeCommand(){ try { diff --git a/src/main/java/command/UnmarkCommand.java b/src/main/java/command/UnmarkCommand.java index 1eb86fe8f..d26a20109 100644 --- a/src/main/java/command/UnmarkCommand.java +++ b/src/main/java/command/UnmarkCommand.java @@ -19,6 +19,10 @@ public UnmarkCommand(String index) { this.index = index; } + /** + * change the task statue to unfinished + * only applicable to finished task + */ @Override public void executeCommand() { try { diff --git a/src/main/java/commandFormat/CommandFormat.java b/src/main/java/commandFormat/CommandFormat.java index 039d8d45d..2d2ebfe5c 100644 --- a/src/main/java/commandFormat/CommandFormat.java +++ b/src/main/java/commandFormat/CommandFormat.java @@ -15,14 +15,14 @@ public static String formattedCommand(String cmd){ } /** - * gives exception when taskNum is not number, or containing non-numerical value + * raises exception when taskNum is not number, or containing non-numerical value */ public static int getTaskNo(String taskNum) { return Integer.parseInt(taskNum); } /** - * use to tackle valid starting input like "todo", "event", "list", + * use to tackle cases with valid starting input like "todo", "event", "list", * but lacking in index or having extra index */ public static boolean missingOrExtraTaskDescription(String[] cmd){ diff --git a/src/main/java/commandFormat/CommandType.java b/src/main/java/commandFormat/CommandType.java index e032ea039..3e612e9d3 100644 --- a/src/main/java/commandFormat/CommandType.java +++ b/src/main/java/commandFormat/CommandType.java @@ -5,6 +5,12 @@ public class CommandType { + /** + * + * @param input represents raw user command + * @return Command object of correct type + * @throws OrientoException if input is in none of the expected cases + */ public static Command parseCommand(String input) throws OrientoException { String[] commandSplits = input.split(" "); diff --git a/src/main/java/exception/OrientoException.java b/src/main/java/exception/OrientoException.java index 10e04a5e4..e719f46a4 100644 --- a/src/main/java/exception/OrientoException.java +++ b/src/main/java/exception/OrientoException.java @@ -13,6 +13,11 @@ private void sendIncorrectMsg(String taskType){ System.out.println("Sorry, your command for " + taskType + " task is not in the correct format. Please try again."); } + /** + * Use to raises exception when incorrect format is found + * tell the users what is correct format for the current input task + * @param taskType represents the task type string such as "todo", "deadline", etc. + */ public void incorrectFormatException(String taskType) { switch (taskType){ case "todo": diff --git a/src/main/java/fileIO/FileIO.java b/src/main/java/fileIO/FileIO.java index eec22a895..ba6e4125d 100644 --- a/src/main/java/fileIO/FileIO.java +++ b/src/main/java/fileIO/FileIO.java @@ -41,6 +41,11 @@ public static void outputFileInitialization() throws IOException { } } + /** + * + * @param path represents the output file path + * @throws IOException only when file is not found and failed to create a new file + */ private static void checkAndCreateFile(String path) throws IOException { File f = new File(path); if(!f.exists()){ @@ -50,6 +55,9 @@ private static void checkAndCreateFile(String path) throws IOException { } } + /** + * similar to checkAndCreateFile + */ private static void checkAndCreateDataFolder() throws IOException { File folder = new File("data"); if (!folder.isDirectory()) { @@ -60,7 +68,7 @@ private static void checkAndCreateDataFolder() throws IOException { } /** - * save the file when exit the program + * save all the current content to another backup file */ public static void backupTaskFile() { try { @@ -71,6 +79,11 @@ public static void backupTaskFile() { } } + /** + * clear all the saved data and set the taskList as an empty list + * use when error occurs in restoring data, e.g. containing message in wrong format + * @throws IOException if failed to access the file + */ private static void clearData() throws IOException { Path clearFile = Paths.get("data/taskList.txt"); if (Files.size(clearFile) != 0) { @@ -81,6 +94,12 @@ private static void clearData() throws IOException { Oriento.taskCount = 0; } + /** + * + * @param filePath path of target file + * @param taskAppend the content to replace + * @throws IOException if failed to access target file + */ public static void overwriteToFile(String filePath, String taskAppend) throws IOException { FileWriter fw = new FileWriter(filePath); fw.write(taskAppend); diff --git a/src/main/java/message/Text.java b/src/main/java/message/Text.java index 87cbfe2e8..87a601814 100644 --- a/src/main/java/message/Text.java +++ b/src/main/java/message/Text.java @@ -38,6 +38,10 @@ private static void printFileContents(String filePath) throws IOException { } } + /** + * Instead of printing from current list, this method print the content from a output file + * @throws IOException if failed to access file + */ public static void printList() throws IOException{ if (taskCount == 0){ System.out.println("You don't have any tasks now. Do you want to add a new task?"); @@ -47,6 +51,10 @@ public static void printList() throws IOException{ } + /** + * write into output file every time new task is created successfully + * @throws IOException if failed to access tasks + */ public static void createTaskSuccessMsg() throws IOException{ System.out.println("Got it. I've added this task:"); System.out.println(list[taskCount]); @@ -68,6 +76,11 @@ private static void writeToFile(String filePath, String taskAppend) throws IOExc fw.close(); } + /** + * tell the user the task is deleted successfully + * decrement the taskCount by 1 + * @param deleteIndex index of the deleted task + */ public static void deleteTaskSuccessMsg(int deleteIndex) { System.out.println("Noted. I've removed this task:"); System.out.println(list[deleteIndex - 1]); diff --git a/src/main/java/task/Event.java b/src/main/java/task/Event.java index 5212ddd75..f84a29be7 100644 --- a/src/main/java/task/Event.java +++ b/src/main/java/task/Event.java @@ -43,6 +43,14 @@ public static Event newEventTask(String userCommand) throws OrientoException, In return new Event(eventTask, start, end); } + /** + * test if the user input period for event is valid + * @param startTime the starting time of event + * @param endTime the end time of event + * @throws InvalidTimeException if the input time is invalid, which could happen in the following cases: + * 1. end time occurs before start time + * 2. end time is over already + */ private static void testTimeInput(String startTime, String endTime) throws InvalidTimeException { LocalDateTime now = LocalDateTime.now(); try{ diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java index d3412802d..a48cf1793 100644 --- a/src/main/java/task/Task.java +++ b/src/main/java/task/Task.java @@ -16,6 +16,12 @@ public String getStatusIcon() { return (isDone ? "X" : " "); // mark done task with X } + /** + * + * @param taskNo the index of the target task + * @param taskCount total number of existing task in the list + * @param list the target taskList (there will only be one list in this application). + */ public void setDone(int taskNo, int taskCount, Task[] list) { if ( (taskNo > taskCount ) || (taskNo <1) ){ System.out.println("Oops! You don't have any task in this positions."); @@ -32,6 +38,9 @@ public void restoreIsDone(){ this.isDone = true; } + /** + * similar to setDone method + */ public void setNotDone(int taskNo, int taskCount, Task[] list) { if ( (taskNo > taskCount ) || (taskNo <1) ){ System.out.println("Oops! You don't have any task in this position."); From 34cd429a18d2053af50fd341240c54ad7b56c3a2 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:33:54 +0800 Subject: [PATCH 35/86] Update README.md --- docs/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 8077118eb..17d88d334 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,10 +1,13 @@ -# User Guide +# User Guide for Oriento ## Features -### Feature-ABC +### Notes about the command format -Description of the feature. +For each type command, a specific command format is required. Please go to the following to look for the details of each command. +e.g. "todo description" means to start with keyword todo and follows by the content + +Both capital letter and small letter are acceptable. But consecutive white space will be eliminated automatically. ### Feature-XYZ From b9e9816031367961c2f503bbd3441677ce79629a Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:36:37 +0800 Subject: [PATCH 36/86] Update README.md --- docs/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/README.md b/docs/README.md index 17d88d334..a42b88bbe 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,8 +5,10 @@ ### Notes about the command format For each type command, a specific command format is required. Please go to the following to look for the details of each command. + e.g. "todo description" means to start with keyword todo and follows by the content + Both capital letter and small letter are acceptable. But consecutive white space will be eliminated automatically. ### Feature-XYZ From 30fa3f2bbe78951c1aeac6496cd6741ab2d981bf Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:36:52 +0800 Subject: [PATCH 37/86] Update README.md --- docs/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index a42b88bbe..c05e63486 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,7 +5,6 @@ ### Notes about the command format For each type command, a specific command format is required. Please go to the following to look for the details of each command. - e.g. "todo description" means to start with keyword todo and follows by the content From 85591e4750ac093c84f9595b1c6416c2e710c408 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:40:22 +0800 Subject: [PATCH 38/86] Update README.md --- docs/README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index c05e63486..796888c7f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,19 +8,21 @@ For each type command, a specific command format is required. Please go to the f e.g. "todo description" means to start with keyword todo and follows by the content -Both capital letter and small letter are acceptable. But consecutive white space will be eliminated automatically. +Both `capital letter` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. ### Feature-XYZ Description of the feature. -## Usage +## Command Type -### `Keyword` - Describe action +### `Todo` - Adding a todo command -Describe the action and its outcome. +A todo tasks is a general task that doesn't need any time requirement. -Example of usage: +Format: todo Descrption + +Example of usage: todo read book `keyword (optional arguments)` From 8a848381c1010662c928c35c42a16f827875fd70 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:40:37 +0800 Subject: [PATCH 39/86] Update README.md --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index 796888c7f..d8291e66a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,6 +5,7 @@ ### Notes about the command format For each type command, a specific command format is required. Please go to the following to look for the details of each command. + e.g. "todo description" means to start with keyword todo and follows by the content From 3a3c454bdab90fc7ca4b72bb303548c01ead3d47 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:41:00 +0800 Subject: [PATCH 40/86] Update README.md --- docs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index d8291e66a..71d144951 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,12 +4,12 @@ ### Notes about the command format -For each type command, a specific command format is required. Please go to the following to look for the details of each command. +- For each type command, a specific command format is required. Please go to the following to look for the details of each command. e.g. "todo description" means to start with keyword todo and follows by the content -Both `capital letter` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. +- Both `capital letter` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. ### Feature-XYZ From 3ba847c5fefc540691b3867ddfd9d4f96eb1dff4 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:41:15 +0800 Subject: [PATCH 41/86] Update README.md --- docs/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 71d144951..18867540d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,8 +5,7 @@ ### Notes about the command format - For each type command, a specific command format is required. Please go to the following to look for the details of each command. - -e.g. "todo description" means to start with keyword todo and follows by the content + e.g. "todo description" means to start with keyword todo and follows by the content - Both `capital letter` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. From c268b0b1188107840dc27b041e70b26e495ad268 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:41:36 +0800 Subject: [PATCH 42/86] Update README.md From 54da8eb50db509da60c9d950f953f81b704566ea Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:41:49 +0800 Subject: [PATCH 43/86] Update README.md --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index 18867540d..31ad46ab9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,6 +5,7 @@ ### Notes about the command format - For each type command, a specific command format is required. Please go to the following to look for the details of each command. + e.g. "todo description" means to start with keyword todo and follows by the content From 00f58b53325ee46df8cdf9c424a4ad9d240692a2 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:42:01 +0800 Subject: [PATCH 44/86] Update README.md --- docs/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 31ad46ab9..dd4ad5a74 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,7 +5,8 @@ ### Notes about the command format - For each type command, a specific command format is required. Please go to the following to look for the details of each command. - + + e.g. "todo description" means to start with keyword todo and follows by the content From bef8a9758010aa94a37f3306e9e329afad5e014f Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:43:39 +0800 Subject: [PATCH 45/86] Update README.md --- docs/README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index dd4ad5a74..6ee19ab1c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -24,14 +24,10 @@ A todo tasks is a general task that doesn't need any time requirement. Format: todo Descrption -Example of usage: todo read book - -`keyword (optional arguments)` +Example: todo read book Expected outcome: -Description of the outcome. - ``` expected output ``` From 80570c9ef5991758ba2ba9890f9a8221a0750132 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:45:00 +0800 Subject: [PATCH 46/86] Update README.md --- docs/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 6ee19ab1c..34314ed21 100644 --- a/docs/README.md +++ b/docs/README.md @@ -20,7 +20,7 @@ Description of the feature. ### `Todo` - Adding a todo command -A todo tasks is a general task that doesn't need any time requirement. +A todo task is a general task that doesn't need any time requirement. Format: todo Descrption @@ -29,5 +29,7 @@ Example: todo read book Expected outcome: ``` -expected output +Got it. I've added this task: +[T][ ] read book +Now you have 1 tasks in the list. ``` From dbc9bc6b8eca454b7d789c5ea594de16e48cabd8 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:56:12 +0800 Subject: [PATCH 47/86] Update README.md --- docs/README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 34314ed21..5507dcbfb 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,6 +12,11 @@ - Both `capital letter` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. +- Some task such as dealine task and event task would required time limit. Please input the time in the following format: + 1. Date format: DD/MM/YYYY. e.g. 21/10/2023 + 2. Date-Time format: DD/MM/YYYY HHMM. e.g. 21/10/2023 1730 +Note that apart from above format, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. + ### Feature-XYZ Description of the feature. @@ -20,7 +25,23 @@ Description of the feature. ### `Todo` - Adding a todo command -A todo task is a general task that doesn't need any time requirement. +A todo task is a general task that doesn't need any time constraint. + +Format: todo Descrption + +Example: todo read book + +Expected outcome: + +``` +Got it. I've added this task: +[T][ ] read book +Now you have 1 tasks in the list. +``` + +### `Deadline` - Adding a deadline command + +A deadline Format: todo Descrption From aa1cba6354875c5a25a258cc6c75f02df99eddb8 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:56:31 +0800 Subject: [PATCH 48/86] Update README.md --- docs/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/README.md b/docs/README.md index 5507dcbfb..f376e2625 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,6 +15,8 @@ - Some task such as dealine task and event task would required time limit. Please input the time in the following format: 1. Date format: DD/MM/YYYY. e.g. 21/10/2023 2. Date-Time format: DD/MM/YYYY HHMM. e.g. 21/10/2023 1730 + + Note that apart from above format, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. ### Feature-XYZ From 27038e56ae95658bd34a6d26ab0a9ae83b49c09f Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:56:56 +0800 Subject: [PATCH 49/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index f376e2625..128c176dd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -17,7 +17,7 @@ 2. Date-Time format: DD/MM/YYYY HHMM. e.g. 21/10/2023 1730 -Note that apart from above format, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. + Note that apart from above format, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. ### Feature-XYZ From 4bd199bc1fd6883e499b524b668308bc25fb1768 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:57:54 +0800 Subject: [PATCH 50/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 128c176dd..f1c88443e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -17,7 +17,7 @@ 2. Date-Time format: DD/MM/YYYY HHMM. e.g. 21/10/2023 1730 - Note that apart from above format, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. + Note that apart from the above formats, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. ### Feature-XYZ From fb1402f48db21d4f3c5ba2ac3c470ea3e56c3e76 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:58:20 +0800 Subject: [PATCH 51/86] Update README.md --- docs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index f1c88443e..8e0318409 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,8 +13,8 @@ - Both `capital letter` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. - Some task such as dealine task and event task would required time limit. Please input the time in the following format: - 1. Date format: DD/MM/YYYY. e.g. 21/10/2023 - 2. Date-Time format: DD/MM/YYYY HHMM. e.g. 21/10/2023 1730 + 1. Date format: `DD/MM/YYYY`. e.g. 21/10/2023 + 2. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 Note that apart from the above formats, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. From 3b83a3a5967ad5c7a1d6e0ccb5752373ecf77198 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:59:59 +0800 Subject: [PATCH 52/86] Update README.md --- docs/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index 8e0318409..8253d1211 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,17 +2,17 @@ ## Features -### Notes about the command format +### Notes about the input command format -- For each type command, a specific command format is required. Please go to the following to look for the details of each command. +- For each type command, a specific `COMMAND FORMAT` is required. Please go to the following to look for the details of each command. e.g. "todo description" means to start with keyword todo and follows by the content -- Both `capital letter` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. +- Both `CAPITAL LETTER` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. -- Some task such as dealine task and event task would required time limit. Please input the time in the following format: +- Tasks such as dealine and event task would required time limit. Please input the time in the following format: 1. Date format: `DD/MM/YYYY`. e.g. 21/10/2023 2. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 From 8ced34eebe77798a65676f55bf1fbdd706b7b478 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 18:00:32 +0800 Subject: [PATCH 53/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 8253d1211..5436e9f61 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,7 +12,7 @@ - Both `CAPITAL LETTER` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. -- Tasks such as dealine and event task would required time limit. Please input the time in the following format: +- Tasks such as dealine and event task would required time limit. Please use the following `time format`: 1. Date format: `DD/MM/YYYY`. e.g. 21/10/2023 2. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 From 1cb1fbc4512e34208cf1b62ba4451535f3792d7e Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 18:56:27 +0800 Subject: [PATCH 54/86] Update README.md --- docs/README.md | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/docs/README.md b/docs/README.md index 5436e9f61..1f0d1bd1f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,19 +5,16 @@ ### Notes about the input command format - For each type command, a specific `COMMAND FORMAT` is required. Please go to the following to look for the details of each command. - - e.g. "todo description" means to start with keyword todo and follows by the content - Both `CAPITAL LETTER` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. - Tasks such as dealine and event task would required time limit. Please use the following `time format`: - 1. Date format: `DD/MM/YYYY`. e.g. 21/10/2023 - 2. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 - - - Note that apart from the above formats, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. + 1. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 + 2. if the 'time is not specified', please use 2359 by default. + Note that apart from the above formats, the current version of app will treat any time input as valid time. + e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. ### Feature-XYZ @@ -25,12 +22,11 @@ Description of the feature. ## Command Type -### `Todo` - Adding a todo command +### `Todo` - Adding a todo task A todo task is a general task that doesn't need any time constraint. -Format: todo Descrption - +Format: `todo Descrption` Example: todo read book Expected outcome: @@ -41,13 +37,28 @@ Got it. I've added this task: Now you have 1 tasks in the list. ``` -### `Deadline` - Adding a deadline command +### `Deadline` - Adding a deadline task -A deadline +A deadline task typically refers to task with a due time. -Format: todo Descrption +Format: `deadline Description /by Date Time` +Example: deadline read book /by 20/10/2022 1200 -Example: todo read book +Expected outcome: + +``` +Got it. I've added this task: +[T][ ] read book +Now you have 1 tasks in the list. +``` + +### `Event` - Adding a event task + +A event task refers to task over a specific period + +Format: `event Description /from Date-Time /to Date-Time` + +Example: event read book /from 20/10/2022 1200 /to 27/10/2022 2359 Expected outcome: From abef09a675daec3c3aeb58cbee90173831f09fd6 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 18:57:14 +0800 Subject: [PATCH 55/86] Update README.md --- docs/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 1f0d1bd1f..51f304365 100644 --- a/docs/README.md +++ b/docs/README.md @@ -42,6 +42,7 @@ Now you have 1 tasks in the list. A deadline task typically refers to task with a due time. Format: `deadline Description /by Date Time` + Example: deadline read book /by 20/10/2022 1200 Expected outcome: @@ -56,7 +57,7 @@ Now you have 1 tasks in the list. A event task refers to task over a specific period -Format: `event Description /from Date-Time /to Date-Time` +Format: `event Description /from Date Time /to Date Time` Example: event read book /from 20/10/2022 1200 /to 27/10/2022 2359 From c47970edd114ecc2656eafe6d14519c0912d50ef Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 18:57:42 +0800 Subject: [PATCH 56/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 51f304365..bc3531fcb 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,7 +12,7 @@ - Tasks such as dealine and event task would required time limit. Please use the following `time format`: 1. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 - 2. if the 'time is not specified', please use 2359 by default. + 2. if the `time is not specified`, please use 2359 by default. Note that apart from the above formats, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. From a55d9016c4eacf6ae5c7768f6141804470b19ee0 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:00:48 +0800 Subject: [PATCH 57/86] Update README.md --- docs/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index bc3531fcb..51ea1d8a5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -43,14 +43,14 @@ A deadline task typically refers to task with a due time. Format: `deadline Description /by Date Time` -Example: deadline read book /by 20/10/2022 1200 +Example: deadline read book /by 22/10/2023 1200 -Expected outcome: +Expected outcome (In Chinese): ``` Got it. I've added this task: -[T][ ] read book -Now you have 1 tasks in the list. +[D][ ] read book (by: 10月 22 2023 12:00 下午) +Now you have 2 tasks in the list. ``` ### `Event` - Adding a event task From 076e890235a1cb45ac2836d8b604951e472ae9be Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:02:23 +0800 Subject: [PATCH 58/86] Update README.md --- docs/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index 51ea1d8a5..9ca306f22 100644 --- a/docs/README.md +++ b/docs/README.md @@ -59,12 +59,12 @@ A event task refers to task over a specific period Format: `event Description /from Date Time /to Date Time` -Example: event read book /from 20/10/2022 1200 /to 27/10/2022 2359 +Example: event read book /from 20/10/2023 1200 /to 27/10/2023 2359 -Expected outcome: +Expected outcome (In Chinese): ``` Got it. I've added this task: -[T][ ] read book -Now you have 1 tasks in the list. +[E][ ] read book (from: 10月 20 2023 12:00 下午 to: 10月 27 2023 11:59 下午) +Now you have 3 tasks in the list. ``` From e74a144e1d7e69c1eda6529b8cb5cae30a3723f7 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:09:17 +0800 Subject: [PATCH 59/86] Update README.md --- docs/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/README.md b/docs/README.md index 9ca306f22..bf8831cb9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -68,3 +68,19 @@ Got it. I've added this task: [E][ ] read book (from: 10月 20 2023 12:00 下午 to: 10月 27 2023 11:59 下午) Now you have 3 tasks in the list. ``` + +## Control Task List + Refers to the following as some alternative methods: + + - **List**: View all the existing tasks created + - **Mark**: Mark an existing task as finished + +### `List` - To view all the existing tasks + +Format: `list` + +### `Mark` - To mark a task as finish + +Release all the tasks inside a list + +Format: `list` From 89afba9a03cdd0bf50c560892e73dddf646aa023 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:11:56 +0800 Subject: [PATCH 60/86] Update README.md --- docs/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/README.md b/docs/README.md index bf8831cb9..ae8eac7d2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -74,6 +74,11 @@ Now you have 3 tasks in the list. - **List**: View all the existing tasks created - **Mark**: Mark an existing task as finished + - **Unmark**: Change a finished task to unfinished + - **Delete**: Remove an existing task, regardless of its finish statue + - **Find**: Look for a specific task + - **Bye**: Exit the program + - **Help**: Look for hints of using the app ### `List` - To view all the existing tasks From 6554b32f883058673f31d53969433e264e3c04f3 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:19:53 +0800 Subject: [PATCH 61/86] Update README.md --- docs/README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/README.md b/docs/README.md index ae8eac7d2..85cccd83d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -70,7 +70,7 @@ Now you have 3 tasks in the list. ``` ## Control Task List - Refers to the following as some alternative methods: + Refers to the following as some alternative methods to use the app: - **List**: View all the existing tasks created - **Mark**: Mark an existing task as finished @@ -80,12 +80,13 @@ Now you have 3 tasks in the list. - **Bye**: Exit the program - **Help**: Look for hints of using the app -### `List` - To view all the existing tasks +### Format of the above funationalities + Please follows either format for the input -Format: `list` - -### `Mark` - To mark a task as finish - -Release all the tasks inside a list - -Format: `list` +1. Withoud index: `list`, `help`, `bye` for the corresponding function. +2. With index: + Format: `Action Index` + Example: mark 1, unmark 1, +3. Find function: + Format: `Find Keyword` + Example: Find read From c9771ed8a33921491fc03c54eefb86bda9f78bef Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:20:30 +0800 Subject: [PATCH 62/86] Update README.md --- docs/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index 85cccd83d..1d429678b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -85,8 +85,8 @@ Now you have 3 tasks in the list. 1. Withoud index: `list`, `help`, `bye` for the corresponding function. 2. With index: - Format: `Action Index` - Example: mark 1, unmark 1, + Format: `Action Index` + Example: mark 1, unmark 1, 3. Find function: - Format: `Find Keyword` - Example: Find read + Format: `Find Keyword` + Example: Find read From f98e169d609cbd441c4d4fc3f91f21356c8ac706 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:20:54 +0800 Subject: [PATCH 63/86] Update README.md --- docs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 1d429678b..8ffba2eb9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -88,5 +88,5 @@ Now you have 3 tasks in the list. Format: `Action Index` Example: mark 1, unmark 1, 3. Find function: - Format: `Find Keyword` - Example: Find read + \nFormat: `Find Keyword` + \nExample: Find read From 05c9b9e4bca45de8541bfc599cf6b48e3d46efcb Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:21:48 +0800 Subject: [PATCH 64/86] Update README.md --- docs/README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index 8ffba2eb9..3e1f2455d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -83,10 +83,16 @@ Now you have 3 tasks in the list. ### Format of the above funationalities Please follows either format for the input -1. Withoud index: `list`, `help`, `bye` for the corresponding function. +1. Withoud index: `list`, `help`, `bye` for the corresponding function + 2. With index: + Format: `Action Index` - Example: mark 1, unmark 1, + + Example: mark 1, unmark 1 + 3. Find function: - \nFormat: `Find Keyword` - \nExample: Find read + + Format: `Find Keyword` + + Example: Find read From 194de5eed6778085e4e840f0fe326fe4e57ad0dc Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:27:28 +0800 Subject: [PATCH 65/86] Update README.md --- docs/README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 3e1f2455d..9f7d95df7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -81,18 +81,29 @@ Now you have 3 tasks in the list. - **Help**: Look for hints of using the app ### Format of the above funationalities - Please follows either format for the input + Please follows either format for the input, where index refers to the task number of a task, which can be found after list out the tasks 1. Withoud index: `list`, `help`, `bye` for the corresponding function 2. With index: - Format: `Action Index` + Format: `Action Index` - Example: mark 1, unmark 1 + Example: mark 1 + + Expected outcome: + + ``` + Nice! I've marked this task as done: + [X] read book + ``` 3. Find function: Format: `Find Keyword` Example: Find read + +### Counter Example +Note that the following case is not yet supported +1. Try to From a8bd91565764abed0958f4143421bce1609e422a Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:29:39 +0800 Subject: [PATCH 66/86] Update README.md --- docs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 9f7d95df7..1d506cbc7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -94,8 +94,8 @@ Now you have 3 tasks in the list. Expected outcome: ``` - Nice! I've marked this task as done: - [X] read book + Nice! I've marked this task as done: + [X] read book ``` 3. Find function: From 88d20d2a0b3fa7ba3061b95413c4eac2fccb46bd Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:36:49 +0800 Subject: [PATCH 67/86] Update README.md --- docs/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/README.md b/docs/README.md index 1d506cbc7..efe3d365a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -85,7 +85,7 @@ Now you have 3 tasks in the list. 1. Withoud index: `list`, `help`, `bye` for the corresponding function -2. With index: +2. With index: Format: `Action Index` @@ -97,13 +97,17 @@ Now you have 3 tasks in the list. Nice! I've marked this task as done: [X] read book ``` + + More examples: unmark 2, delete 10 3. Find function: - Format: `Find Keyword` + Format: `Find Content` - Example: Find read + Example: Find read book -### Counter Example -Note that the following case is not yet supported -1. Try to +### Limitations on the functions +Note that each functions may limit its usage +1. Find function could only look for a task content. Search by time is `NOT` supported yet +2. Delete, mark, and unmark function can only control one targte task at each time of execution +3. Don't use list with index as it is not yet supported From d89c6264dc6c9b141e0f5e216a8b7c8efa43196c Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:37:58 +0800 Subject: [PATCH 68/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index efe3d365a..fcc2e9a17 100644 --- a/docs/README.md +++ b/docs/README.md @@ -107,7 +107,7 @@ Now you have 3 tasks in the list. Example: Find read book ### Limitations on the functions -Note that each functions may limit its usage +Note that each functions may limit its usage. And these could possibly be supported in the future. 1. Find function could only look for a task content. Search by time is `NOT` supported yet 2. Delete, mark, and unmark function can only control one targte task at each time of execution 3. Don't use list with index as it is not yet supported From 70f7f2bf82fbcb7bbd93455201f259012ec790d9 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:38:29 +0800 Subject: [PATCH 69/86] Update README.md --- docs/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index fcc2e9a17..0439b8b0d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -16,9 +16,6 @@ Note that apart from the above formats, the current version of app will treat any time input as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. -### Feature-XYZ - -Description of the feature. ## Command Type From 6d96bf248520d283cffbf4757e8977463448884c Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:43:03 +0800 Subject: [PATCH 70/86] Update README.md --- docs/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 0439b8b0d..05443056a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,10 +10,10 @@ - Both `CAPITAL LETTER` and `small letter` are acceptable. But consecutive white space will be eliminated automatically. -- Tasks such as dealine and event task would required time limit. Please use the following `time format`: +- Tasks such as dealine and event task would required time limit. Please use only `Date Time`: 1. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 2. if the `time is not specified`, please use 2359 by default. - Note that apart from the above formats, the current version of app will treat any time input as valid time. + General Time: Note that apart from the above formats, the current version of app will treat `any time input` as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. @@ -108,3 +108,4 @@ Note that each functions may limit its usage. And these could possibly be suppor 1. Find function could only look for a task content. Search by time is `NOT` supported yet 2. Delete, mark, and unmark function can only control one targte task at each time of execution 3. Don't use list with index as it is not yet supported +4. Current only Date Time format is supported. Date format is not allowed. But you can use it as a general time format. From a1d77ec93570bbb7c2ec8270c46241eee3869b33 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:43:16 +0800 Subject: [PATCH 71/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 05443056a..eba917daf 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,7 +13,7 @@ - Tasks such as dealine and event task would required time limit. Please use only `Date Time`: 1. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 2. if the `time is not specified`, please use 2359 by default. - General Time: Note that apart from the above formats, the current version of app will treat `any time input` as valid time. + General Time: Note that apart from the above formats, the current version of app will treat `any time input` as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. From 2313371581db78ceca186217a1982ab9cbe69ff9 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:43:30 +0800 Subject: [PATCH 72/86] Update README.md --- docs/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index eba917daf..265cf858e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,7 +13,8 @@ - Tasks such as dealine and event task would required time limit. Please use only `Date Time`: 1. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 2. if the `time is not specified`, please use 2359 by default. - General Time: Note that apart from the above formats, the current version of app will treat `any time input` as valid time. + + General Time: Note that apart from the above formats, the current version of app will treat `any time input` as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. From 52df4637d3cbb976ab19ca987110a4eac1cec6e9 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:44:02 +0800 Subject: [PATCH 73/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 265cf858e..8e96187aa 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,7 +14,7 @@ 1. Date-Time format: `DD/MM/YYYY HHMM`. e.g. 21/10/2023 1730 2. if the `time is not specified`, please use 2359 by default. - General Time: Note that apart from the above formats, the current version of app will treat `any time input` as valid time. + General Time: Apart from the DateTime format, the current version of app will treat `any time input` as valid time. e.g. Friday, Birthday of Ethan, etc. Please make wise use of the time input. From 20bc921b2f7d4f0d05b0ffc624f1b0c3a5fade60 Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sat, 21 Oct 2023 19:46:15 +0800 Subject: [PATCH 74/86] Bugs fixed in using empty find command and mulfunctions of validating time --- data/backup_taskList.txt | 5 +++-- data/taskList.txt | 5 +++-- src/main/java/Oriento/Oriento.java | 2 +- src/main/java/command/DeadlineCommand.java | 2 +- src/main/java/command/EventCommand.java | 2 +- src/main/java/command/UnmarkCommand.java | 5 +++-- src/main/java/commandFormat/CommandFormat.java | 3 ++- src/main/java/commandFormat/TimeParser.java | 2 +- src/main/java/exception/InvalidTimeException.java | 1 + src/main/java/task/Event.java | 4 ++-- 10 files changed, 18 insertions(+), 13 deletions(-) diff --git a/data/backup_taskList.txt b/data/backup_taskList.txt index adeb3f1ba..94d5e044f 100644 --- a/data/backup_taskList.txt +++ b/data/backup_taskList.txt @@ -1,2 +1,3 @@ -1. [T][ ] ok -2. [T][ ] this is 2 +1. [T][X] read book +2. [D][X] read book (by: 10月 22 2023 12:00 下午) +3. [E][ ] read book (from: 10月 20 2023 12:00 下午 to: 10月 27 2023 11:59 下午) diff --git a/data/taskList.txt b/data/taskList.txt index adeb3f1ba..94d5e044f 100644 --- a/data/taskList.txt +++ b/data/taskList.txt @@ -1,2 +1,3 @@ -1. [T][ ] ok -2. [T][ ] this is 2 +1. [T][X] read book +2. [D][X] read book (by: 10月 22 2023 12:00 下午) +3. [E][ ] read book (from: 10月 20 2023 12:00 下午 to: 10月 27 2023 11:59 下午) diff --git a/src/main/java/Oriento/Oriento.java b/src/main/java/Oriento/Oriento.java index d3d03797d..5923d9430 100644 --- a/src/main/java/Oriento/Oriento.java +++ b/src/main/java/Oriento/Oriento.java @@ -23,7 +23,7 @@ public class Oriento { public static int taskCount = 0; public static Task[] list = new Task[100]; - public static void main(String[] args) throws IOException, OrientoException { + public static void main(String[] args) throws IOException { Text.printWelcomeMessage(); Scanner keyboard = new Scanner(System.in); FileIO.outputFileInitialization(); diff --git a/src/main/java/command/DeadlineCommand.java b/src/main/java/command/DeadlineCommand.java index 3d56ba9ba..c602b702d 100644 --- a/src/main/java/command/DeadlineCommand.java +++ b/src/main/java/command/DeadlineCommand.java @@ -34,7 +34,7 @@ public void executeCommand(){ } catch (IOException io){ System.out.println("OMG! Something went wrong! Please check if the source files are available."); } catch (InvalidTimeException ite){ - System.out.println("Please check your schedule."); + System.out.println("Deadline is over already!"); } } diff --git a/src/main/java/command/EventCommand.java b/src/main/java/command/EventCommand.java index 46bed6bbc..d5ee461b0 100644 --- a/src/main/java/command/EventCommand.java +++ b/src/main/java/command/EventCommand.java @@ -31,7 +31,7 @@ public void executeCommand(){ } catch (IOException io){ System.out.println("OMG! Something went wrong! Please check if the source files are available."); } catch (InvalidTimeException d){ - System.out.println("Please check your period again."); + System.out.println(d.getMessage()); } } diff --git a/src/main/java/command/UnmarkCommand.java b/src/main/java/command/UnmarkCommand.java index d26a20109..5e4c774ae 100644 --- a/src/main/java/command/UnmarkCommand.java +++ b/src/main/java/command/UnmarkCommand.java @@ -9,11 +9,12 @@ import static fileIO.FileIO.overwriteToFile; public class UnmarkCommand extends Command{ + + private String index; + /** * similar to mark */ - private String index; - public UnmarkCommand(String index) { super(false); this.index = index; diff --git a/src/main/java/commandFormat/CommandFormat.java b/src/main/java/commandFormat/CommandFormat.java index 2d2ebfe5c..0a98ec6cf 100644 --- a/src/main/java/commandFormat/CommandFormat.java +++ b/src/main/java/commandFormat/CommandFormat.java @@ -28,7 +28,8 @@ public static int getTaskNo(String taskNum) { public static boolean missingOrExtraTaskDescription(String[] cmd){ if (cmd.length == 1){ if(cmd[0].equals("todo") || cmd[0].equals("event") || cmd[0].equals("deadline") - || cmd[0].equals("mark") || cmd[0].equals("unmark") || cmd[0].equals("delete")){ + || cmd[0].equals("mark") || cmd[0].equals("unmark") || cmd[0].equals("delete") + || cmd[0].equals("find")){ System.out.println("Please describe your target."); return true; } diff --git a/src/main/java/commandFormat/TimeParser.java b/src/main/java/commandFormat/TimeParser.java index 5acf3fb25..1c72141b3 100644 --- a/src/main/java/commandFormat/TimeParser.java +++ b/src/main/java/commandFormat/TimeParser.java @@ -12,7 +12,7 @@ public class TimeParser { * @return LocalDataTIme object */ public static LocalDateTime parseDateTime(String input) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy Hmm"); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HHmm"); return LocalDateTime.parse(input, formatter); } diff --git a/src/main/java/exception/InvalidTimeException.java b/src/main/java/exception/InvalidTimeException.java index a87602e1a..97c1ef503 100644 --- a/src/main/java/exception/InvalidTimeException.java +++ b/src/main/java/exception/InvalidTimeException.java @@ -5,4 +5,5 @@ public class InvalidTimeException extends Exception { public InvalidTimeException(String message) { super(message); } + } diff --git a/src/main/java/task/Event.java b/src/main/java/task/Event.java index f84a29be7..970ee420e 100644 --- a/src/main/java/task/Event.java +++ b/src/main/java/task/Event.java @@ -22,7 +22,7 @@ public Event(String description, String start, String end) { * if failed to parse input, assume the user is true * @InvalidTimeException caught in EventCommand class */ - public static Event newEventTask(String userCommand) throws OrientoException, InvalidTimeException { + public static Event newEventTask(String userCommand) throws OrientoException,InvalidTimeException { //command format: event project meeting /from Mon 2pm /to 4pm if (!(userCommand.contains("/from")) || !(userCommand.contains("/to"))){ throw new OrientoException("Oh, no! There is no '/from' or '/to' "); @@ -52,10 +52,10 @@ public static Event newEventTask(String userCommand) throws OrientoException, In * 2. end time is over already */ private static void testTimeInput(String startTime, String endTime) throws InvalidTimeException { - LocalDateTime now = LocalDateTime.now(); try{ LocalDateTime start = TimeParser.parseDateTime(startTime); LocalDateTime end = TimeParser.parseDateTime(endTime); + LocalDateTime now = LocalDateTime.now(); if(end.isBefore(now)){ throw new InvalidTimeException("The event is ended. Please check the end time again."); } From c25848c2543feebb3d3b3b2c9d88847dec2d6e5d Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:51:59 +0800 Subject: [PATCH 75/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 8e96187aa..1435be09f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -109,4 +109,4 @@ Note that each functions may limit its usage. And these could possibly be suppor 1. Find function could only look for a task content. Search by time is `NOT` supported yet 2. Delete, mark, and unmark function can only control one targte task at each time of execution 3. Don't use list with index as it is not yet supported -4. Current only Date Time format is supported. Date format is not allowed. But you can use it as a general time format. +4. Current only Date Time format is supported. Date format is not allowed. But you can use it as a general time format. However, general time format `Does NOT` support time validating function. From 7e8712deaa03d1ec38205a944408d8c4f727a0ba Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:59:55 +0800 Subject: [PATCH 76/86] Update README.md --- docs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 1435be09f..63ff41e5c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -81,9 +81,9 @@ Now you have 3 tasks in the list. ### Format of the above funationalities Please follows either format for the input, where index refers to the task number of a task, which can be found after list out the tasks -1. Withoud index: `list`, `help`, `bye` for the corresponding function +1. **Withoud index**: `list`, `help`, `bye` for the corresponding function -2. With index: +2. **With index**: Format: `Action Index` @@ -98,7 +98,7 @@ Now you have 3 tasks in the list. More examples: unmark 2, delete 10 -3. Find function: +3. **Find function**: Format: `Find Content` From 564d7d84709f2feb39eb5e73e567762b895044f0 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 20:03:44 +0800 Subject: [PATCH 77/86] Update README.md --- docs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 63ff41e5c..193e3b976 100644 --- a/docs/README.md +++ b/docs/README.md @@ -81,9 +81,9 @@ Now you have 3 tasks in the list. ### Format of the above funationalities Please follows either format for the input, where index refers to the task number of a task, which can be found after list out the tasks -1. **Withoud index**: `list`, `help`, `bye` for the corresponding function +### 1. `Without Index` : `list`, `help`, `bye` for the corresponding function -2. **With index**: +### 2. `With index` - Control a target task: Format: `Action Index` @@ -98,7 +98,7 @@ Now you have 3 tasks in the list. More examples: unmark 2, delete 10 -3. **Find function**: +### 3. `Find` - look for a task: Format: `Find Content` From aa8a38c3c26022372c4cde8cba44486cd7193d49 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 20:04:56 +0800 Subject: [PATCH 78/86] Update README.md --- docs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 193e3b976..0a87bde87 100644 --- a/docs/README.md +++ b/docs/README.md @@ -81,9 +81,9 @@ Now you have 3 tasks in the list. ### Format of the above funationalities Please follows either format for the input, where index refers to the task number of a task, which can be found after list out the tasks -### 1. `Without Index` : `list`, `help`, `bye` for the corresponding function +### `Without Index` : `list`, `help`, `bye` for the corresponding function -### 2. `With index` - Control a target task: +### `With index` - Control a target task: Format: `Action Index` @@ -98,7 +98,7 @@ Now you have 3 tasks in the list. More examples: unmark 2, delete 10 -### 3. `Find` - look for a task: +### `Find` - look for a task: Format: `Find Content` From dc6e6484a809dbee46174b6aa67a3fd3fe1a599c Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 20:05:37 +0800 Subject: [PATCH 79/86] Update README.md --- docs/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index 0a87bde87..e0c2f3ba3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -81,11 +81,11 @@ Now you have 3 tasks in the list. ### Format of the above funationalities Please follows either format for the input, where index refers to the task number of a task, which can be found after list out the tasks -### `Without Index` : `list`, `help`, `bye` for the corresponding function +### 1. `Without Index` : `list`, `help`, `bye` for the corresponding function -### `With index` - Control a target task: +### 2. `With index` - Control a target task: - Format: `Action Index` + Format: Action Index Example: mark 1 @@ -98,9 +98,9 @@ Now you have 3 tasks in the list. More examples: unmark 2, delete 10 -### `Find` - look for a task: +### 3. `Find` - look for a task: - Format: `Find Content` + Format: Find Content Example: Find read book From 303fd3d422ebe78b70d7d89ec65a2f4997375afc Mon Sep 17 00:00:00 2001 From: "MSI\\jyben" Date: Sat, 21 Oct 2023 23:17:52 +0800 Subject: [PATCH 80/86] Add more documentations --- src/main/java/command/UnmarkCommand.java | 1 + src/main/java/commandFormat/CommandFormat.java | 9 ++++++--- src/main/java/commandFormat/CommandType.java | 3 ++- src/main/java/commandFormat/TimeParser.java | 6 ++++-- src/main/java/fileIO/FileIO.java | 7 +++++++ src/main/java/task/Task.java | 4 ++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/command/UnmarkCommand.java b/src/main/java/command/UnmarkCommand.java index 5e4c774ae..31c112c88 100644 --- a/src/main/java/command/UnmarkCommand.java +++ b/src/main/java/command/UnmarkCommand.java @@ -23,6 +23,7 @@ public UnmarkCommand(String index) { /** * change the task statue to unfinished * only applicable to finished task + * It gives error message when wrong index is used or the output file cannot be found */ @Override public void executeCommand() { diff --git a/src/main/java/commandFormat/CommandFormat.java b/src/main/java/commandFormat/CommandFormat.java index 0a98ec6cf..66906ffb2 100644 --- a/src/main/java/commandFormat/CommandFormat.java +++ b/src/main/java/commandFormat/CommandFormat.java @@ -2,8 +2,10 @@ public class CommandFormat { - /** - * transform to smaller letter, removing leading and ending space, and contract any consecutive space + + /**This method is to transform the user command into 'expected' format for parsing purpose + * User Input is transformed to smaller letter, + * removed leading and ending space, and contracted any consecutive space * @param cmd user command * @return updated command */ @@ -23,7 +25,8 @@ public static int getTaskNo(String taskNum) { /** * use to tackle cases with valid starting input like "todo", "event", "list", - * but lacking in index or having extra index + * but lacking in index or having extra index/content + * e.g. find command should have content while list should not */ public static boolean missingOrExtraTaskDescription(String[] cmd){ if (cmd.length == 1){ diff --git a/src/main/java/commandFormat/CommandType.java b/src/main/java/commandFormat/CommandType.java index 3e612e9d3..b49c30168 100644 --- a/src/main/java/commandFormat/CommandType.java +++ b/src/main/java/commandFormat/CommandType.java @@ -6,7 +6,8 @@ public class CommandType { /** - * + * The parseCommand will parse the user input and generate a respective command object + * e.g. if the user command aims to add a todo task, it should return a todo command * @param input represents raw user command * @return Command object of correct type * @throws OrientoException if input is in none of the expected cases diff --git a/src/main/java/commandFormat/TimeParser.java b/src/main/java/commandFormat/TimeParser.java index 1c72141b3..f42fc145b 100644 --- a/src/main/java/commandFormat/TimeParser.java +++ b/src/main/java/commandFormat/TimeParser.java @@ -6,8 +6,10 @@ import java.util.Locale; public class TimeParser { + /** - * + * This changes a string of time into a dataTIme object + * It only supports string with format of DDMMYYYY HHMM format * @param input time string * @return LocalDataTIme object */ @@ -17,7 +19,7 @@ public static LocalDateTime parseDateTime(String input) { } /** - * + * This method can transform a dataTime object into a string information of dateTime * @param dateTime object of LocalDateTime * @return converted string */ diff --git a/src/main/java/fileIO/FileIO.java b/src/main/java/fileIO/FileIO.java index ba6e4125d..bf50ba93e 100644 --- a/src/main/java/fileIO/FileIO.java +++ b/src/main/java/fileIO/FileIO.java @@ -182,6 +182,13 @@ private static String ddlExtract(String description) { return description.substring(startIndex, endIndex); } + /** + * This method will restore the saved data, but scanner the old data, + * and simple generate a new taskList again with the saved data + * @param DATA_PATH path of backUp file + * @throws IOException if failed to access files + * Exception is generated when creating a task using the saved data + */ public static void restoreSavedData(String DATA_PATH) throws IOException, OrientoException, IndexOutOfBoundsException{ try { File file = new File(DATA_PATH); diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java index a48cf1793..53e6b3112 100644 --- a/src/main/java/task/Task.java +++ b/src/main/java/task/Task.java @@ -67,8 +67,8 @@ public static Task[] updatedTaskList(int indexOfDelete){ } /** - * - * @return string contains all task data + * This method will only read the global taskList + * @return string contains all task data inside the global taskList */ public static String getConcatenateTasks() { StringBuilder stringBuilder = new StringBuilder(); From dbb5b0b42aaed2e4dc9299df9f844c5a65bb2cfd Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:30:01 +0800 Subject: [PATCH 81/86] Update README.md --- docs/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/README.md b/docs/README.md index e0c2f3ba3..248e7a199 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,19 @@ # User Guide for Oriento +Oriento is a desktop application designed to help you manage your tasks and guide your life in the right direction. It is optimized for use through Command Line Interface(CLI). If you can type face, it would run faster than a traditional GUI app. + +## Quick Start + +1. Ensure you have Java `11` or above installed in your Computer. + +2. Download the latest `ip.jar` from + +3. Copy the file to the folder you want to use as the *home folder* for Oriento. + +4. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar ip.jar` command to run the application. + +5. Use `list` command to see if you have any saved task data + ## Features ### Notes about the input command format From 2a2d9a162605e59fb1f15ab432558765c84e11c3 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:32:17 +0800 Subject: [PATCH 82/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 248e7a199..ebc6957a1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,7 +6,7 @@ Oriento is a desktop application designed to help you manage your tasks and guid 1. Ensure you have Java `11` or above installed in your Computer. -2. Download the latest `ip.jar` from +2. Download the latest `ip.jar` from https://github.com/J-Y-Yan/ip/releases. 3. Copy the file to the folder you want to use as the *home folder* for Oriento. From 9dd679e2eabe87852b003cf3ef16cb3225cfff4d Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:34:13 +0800 Subject: [PATCH 83/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index ebc6957a1..416a0439d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,7 +6,7 @@ Oriento is a desktop application designed to help you manage your tasks and guid 1. Ensure you have Java `11` or above installed in your Computer. -2. Download the latest `ip.jar` from https://github.com/J-Y-Yan/ip/releases. +2. Download the latest `ip.jar` from here(https://github.com/J-Y-Yan/ip/releases). 3. Copy the file to the folder you want to use as the *home folder* for Oriento. From 8b13eb104c37e812ec0ee1d9899a0fb4da0e13d3 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:34:32 +0800 Subject: [PATCH 84/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 416a0439d..9acde9965 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,7 +6,7 @@ Oriento is a desktop application designed to help you manage your tasks and guid 1. Ensure you have Java `11` or above installed in your Computer. -2. Download the latest `ip.jar` from here(https://github.com/J-Y-Yan/ip/releases). +2. Download the latest `ip.jar` from [here](https://github.com/J-Y-Yan/ip/releases). 3. Copy the file to the folder you want to use as the *home folder* for Oriento. From 815481eb27645837b491be004c653abe5873ff8d Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:35:04 +0800 Subject: [PATCH 85/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 9acde9965..99c14258a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,7 +6,7 @@ Oriento is a desktop application designed to help you manage your tasks and guid 1. Ensure you have Java `11` or above installed in your Computer. -2. Download the latest `ip.jar` from [here](https://github.com/J-Y-Yan/ip/releases). +2. Download the latest `ip.jar` from [here](https://github.com/J-Y-Yan/ip/releases/download/v2.0.2/ip.jar). 3. Copy the file to the folder you want to use as the *home folder* for Oriento. From 5996557d43f6c9a0e627ab896c26ed4091538624 Mon Sep 17 00:00:00 2001 From: J-Y-Yan <142566176+J-Y-Yan@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:41:33 +0800 Subject: [PATCH 86/86] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 99c14258a..d24fb1775 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ # User Guide for Oriento -Oriento is a desktop application designed to help you manage your tasks and guide your life in the right direction. It is optimized for use through Command Line Interface(CLI). If you can type face, it would run faster than a traditional GUI app. +Oriento is a desktop application designed to help you manage your tasks and guide your life in the right direction. It is optimized for use through Command Line Interface(CLI). If you can type fast, it would run faster than a traditional GUI app. ## Quick Start