From b6c7c46c92a8edd93d1148170b2380a455440e35 Mon Sep 17 00:00:00 2001 From: rsiowkf Date: Sun, 24 Aug 2025 14:31:06 +0800 Subject: [PATCH 01/12] Changed the description of README to not have the original message --- README.md | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/README.md b/README.md index af0309a9e..c6c4b3612 100644 --- a/README.md +++ b/README.md @@ -1,26 +1 @@ -# Duke project template - -This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it. - -## Setting up in Intellij - -Prerequisites: JDK 17, update Intellij to the most recent version. - -1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first) -1. Open the project into Intellij as follows: - 1. Click `Open`. - 1. Select the project directory, and click `OK`. - 1. If there are any further prompts, accept the defaults. -1. Configure the project to use **JDK 17** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).
- In the same dialog, set the **Project language level** field to the `SDK default` option. -1. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output: - ``` - Hello from - ____ _ - | _ \ _ _| | _____ - | | | | | | | |/ / _ \ - | |_| | |_| | < __/ - |____/ \__,_|_|\_\___| - ``` - -**Warning:** Keep the `src\main\java` folder as the root folder for Java files (i.e., don't rename those folders or move Java files to another folder outside of this folder path), as this is the default location some tools (e.g., Gradle) expect to find Java files. +Ryan's Project! From a8dd311dd5f8f81e336400df4c659fd1f9103c29 Mon Sep 17 00:00:00 2001 From: rsiowkf Date: Sun, 24 Aug 2025 14:36:27 +0800 Subject: [PATCH 02/12] Added Ryan.java and changed Duke's name to Siao --- docs/README.md | 2 +- src/Ryan.java | 5 +++++ src/main/java/Duke.java | 10 ---------- src/main/java/Siao.java | 7 +++++++ text-ui-test/runtest.bat | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 src/Ryan.java delete mode 100644 src/main/java/Duke.java create mode 100644 src/main/java/Siao.java diff --git a/docs/README.md b/docs/README.md index 47b9f984f..ff32f2635 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,4 +1,4 @@ -# Duke User Guide +# Siao User Guide // Update the title above to match the actual product name diff --git a/src/Ryan.java b/src/Ryan.java new file mode 100644 index 000000000..05b177c12 --- /dev/null +++ b/src/Ryan.java @@ -0,0 +1,5 @@ +public class Ryan { + public static void main(String[] args) { + System.out.println("Hello! I'm Ryan!"); + } +} \ No newline at end of file diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java deleted file mode 100644 index 5d313334c..000000000 --- a/src/main/java/Duke.java +++ /dev/null @@ -1,10 +0,0 @@ -public class Duke { - public static void main(String[] args) { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); - } -} diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java new file mode 100644 index 000000000..7a1368937 --- /dev/null +++ b/src/main/java/Siao.java @@ -0,0 +1,7 @@ +public class Siao { + public static void main(String[] args) { + System.out.println("Hello! I'm Siao!"); + System.out.println("What can I do for you?"); + System.out.println("Bye. Hope to see you again soon!"); + } +} diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat index 087374464..b8e3964c7 100644 --- a/text-ui-test/runtest.bat +++ b/text-ui-test/runtest.bat @@ -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 Siao < input.txt > ACTUAL.TXT REM compare the output to the expected output FC ACTUAL.TXT EXPECTED.TXT From e24ac4b7fa546111c7f82748cef6ec842bb5e600 Mon Sep 17 00:00:00 2001 From: rsiowkf Date: Sun, 24 Aug 2025 14:36:55 +0800 Subject: [PATCH 03/12] Removed Ryan.java --- src/Ryan.java | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/Ryan.java diff --git a/src/Ryan.java b/src/Ryan.java deleted file mode 100644 index 05b177c12..000000000 --- a/src/Ryan.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Ryan { - public static void main(String[] args) { - System.out.println("Hello! I'm Ryan!"); - } -} \ No newline at end of file From ec0b1b60652adf67f651e9d7e16011c5cbb80736 Mon Sep 17 00:00:00 2001 From: rsiowkf Date: Sun, 24 Aug 2025 14:48:38 +0800 Subject: [PATCH 04/12] To remove bye, and ask for user's name --- src/main/java/Siao.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java index 7a1368937..091515072 100644 --- a/src/main/java/Siao.java +++ b/src/main/java/Siao.java @@ -2,6 +2,6 @@ public class Siao { public static void main(String[] args) { System.out.println("Hello! I'm Siao!"); System.out.println("What can I do for you?"); - System.out.println("Bye. Hope to see you again soon!"); + System.out.println("What is your name?"); } } From 45f0473dd91877a2b2fc31e1da4c0f4db3af529c Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 28 Aug 2025 15:35:34 +0800 Subject: [PATCH 05/12] Changed to say Bye instead of asking for name --- src/main/java/Siao.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java index 091515072..7a1368937 100644 --- a/src/main/java/Siao.java +++ b/src/main/java/Siao.java @@ -2,6 +2,6 @@ public class Siao { public static void main(String[] args) { System.out.println("Hello! I'm Siao!"); System.out.println("What can I do for you?"); - System.out.println("What is your name?"); + System.out.println("Bye. Hope to see you again soon!"); } } From 78154d4478999f820746900b57ea7797d000c513 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 28 Aug 2025 15:38:53 +0800 Subject: [PATCH 06/12] Removed an exclamation mark --- src/main/java/Siao.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java index 7a1368937..becada62e 100644 --- a/src/main/java/Siao.java +++ b/src/main/java/Siao.java @@ -2,6 +2,6 @@ public class Siao { public static void main(String[] args) { System.out.println("Hello! I'm Siao!"); System.out.println("What can I do for you?"); - System.out.println("Bye. Hope to see you again soon!"); + System.out.println("Bye. Hope to see you again soon"); } } From 824e4b92ac357176d97e49f50cf0663ec1cf0936 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 28 Aug 2025 15:39:04 +0800 Subject: [PATCH 07/12] Revert "Removed an exclamation mark" This reverts commit 78154d4478999f820746900b57ea7797d000c513. --- src/main/java/Siao.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java index becada62e..7a1368937 100644 --- a/src/main/java/Siao.java +++ b/src/main/java/Siao.java @@ -2,6 +2,6 @@ public class Siao { public static void main(String[] args) { System.out.println("Hello! I'm Siao!"); System.out.println("What can I do for you?"); - System.out.println("Bye. Hope to see you again soon"); + System.out.println("Bye. Hope to see you again soon!"); } } From 26e433f9fe25dd75490c40da02a0562c15e6f4ec Mon Sep 17 00:00:00 2001 From: rsiowkf Date: Sun, 31 Aug 2025 15:57:21 +0800 Subject: [PATCH 08/12] level-1: Echo edits --- src/main/java/Siao.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java index 7a1368937..a8d86940f 100644 --- a/src/main/java/Siao.java +++ b/src/main/java/Siao.java @@ -1,7 +1,18 @@ +import java.util.Scanner; + public class Siao { public static void main(String[] args) { System.out.println("Hello! I'm Siao!"); + + Scanner input = new Scanner(System.in); System.out.println("What can I do for you?"); + String line = input.nextLine(); + + while(!line.equalsIgnoreCase("bye")){ + System.out.printf("---------------------------------\n" + line + "\n---------------------------------\n"); + line = input.nextLine(); + } + System.out.println("---------------------------------"); System.out.println("Bye. Hope to see you again soon!"); } } From 7ccc17f2f83420defd8c2bbad649eaad768090ac Mon Sep 17 00:00:00 2001 From: rsiowkf Date: Sun, 31 Aug 2025 16:29:51 +0800 Subject: [PATCH 09/12] level 2: Add, List --- src/main/java/Siao.java | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java index a8d86940f..c163d6a21 100644 --- a/src/main/java/Siao.java +++ b/src/main/java/Siao.java @@ -1,6 +1,28 @@ +import java.util.Arrays; import java.util.Scanner; public class Siao { + + public static void printDividerLine(){ + System.out.println("---------------------------------"); + } + + public static void printList(String[] list) { + printDividerLine(); + int j = 1; + for (int i = 0; i < list.length; i++) { + System.out.printf(j + "." + list[i] + "\n"); + j++; + } + printDividerLine(); + } + + public static void printAction(String action){ + printDividerLine(); + System.out.printf("added: " + action + "\n"); + printDividerLine(); + } + public static void main(String[] args) { System.out.println("Hello! I'm Siao!"); @@ -8,10 +30,22 @@ public static void main(String[] args) { System.out.println("What can I do for you?"); String line = input.nextLine(); + String[] list = new String[100]; + int matchCount = 0; + while(!line.equalsIgnoreCase("bye")){ - System.out.printf("---------------------------------\n" + line + "\n---------------------------------\n"); + printAction(line); + list[matchCount] = line; + matchCount++; line = input.nextLine(); + + if (line.equalsIgnoreCase("list")){ + printList(Arrays.copyOf(list, matchCount)); + line = input.nextLine(); + } } + + System.out.println("---------------------------------"); System.out.println("Bye. Hope to see you again soon!"); } From 58a747d5458a386c18327ff18b7881f3ea56fdc6 Mon Sep 17 00:00:00 2001 From: rsiowkf Date: Sun, 31 Aug 2025 16:40:38 +0800 Subject: [PATCH 10/12] level 2: Add, List --- src/main/java/Siao.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java index c163d6a21..ab15872c1 100644 --- a/src/main/java/Siao.java +++ b/src/main/java/Siao.java @@ -24,7 +24,7 @@ public static void printAction(String action){ } public static void main(String[] args) { - System.out.println("Hello! I'm Siao!"); + System.out.println("Hello! I'm Siao!!"); Scanner input = new Scanner(System.in); System.out.println("What can I do for you?"); From 117939cd531a274434e7d6b4f34bead765b50fa1 Mon Sep 17 00:00:00 2001 From: rsiowkf Date: Sun, 31 Aug 2025 18:21:47 +0800 Subject: [PATCH 11/12] level 3: Mark as Done --- src/main/java/Siao.java | 70 ++++++++++++++++++++++++++++------------- src/main/java/Task.java | 41 ++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 22 deletions(-) create mode 100644 src/main/java/Task.java diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java index ab15872c1..a42499cb2 100644 --- a/src/main/java/Siao.java +++ b/src/main/java/Siao.java @@ -7,16 +7,21 @@ public static void printDividerLine(){ System.out.println("---------------------------------"); } - public static void printList(String[] list) { + public static void printList(Task[] list) { printDividerLine(); - int j = 1; + int indexNumber = 1; for (int i = 0; i < list.length; i++) { - System.out.printf(j + "." + list[i] + "\n"); - j++; + if(list[i] == null) { + System.out.println("-----------End Of List-----------"); + break; + } + System.out.printf("%d. [%s] %s\n", indexNumber, list[i].getStatusIcon(), list[i].getDescription()); + indexNumber++; } printDividerLine(); } + public static void printAction(String action){ printDividerLine(); System.out.printf("added: " + action + "\n"); @@ -24,29 +29,50 @@ public static void printAction(String action){ } public static void main(String[] args) { - System.out.println("Hello! I'm Siao!!"); + System.out.println("Hello! I'm Siao!!"); + + Scanner input = new Scanner(System.in); + System.out.println("What can I do for you?"); + String line = input.nextLine(); + + Task[] list = new Task[100]; + int matchCount = 0; - Scanner input = new Scanner(System.in); - System.out.println("What can I do for you?"); - String line = input.nextLine(); + while(!line.equalsIgnoreCase("bye")){ + String[] splitInput = line.split(" "); + String command = splitInput[0]; - String[] list = new String[100]; - int matchCount = 0; + switch (command){ - while(!line.equalsIgnoreCase("bye")){ - printAction(line); - list[matchCount] = line; - matchCount++; - line = input.nextLine(); + case "list": + printList(list); + line = input.nextLine(); + break; - if (line.equalsIgnoreCase("list")){ - printList(Arrays.copyOf(list, matchCount)); - line = input.nextLine(); - } - } + case "mark": + int markIndex = Integer.parseInt(splitInput[1]) - 1; + list[markIndex].markDone(); + list[markIndex].printMarkDone(); + line = input.nextLine(); + break; + case "unmark": + int unmarkIndex = Integer.parseInt(splitInput[1]) - 1; + list[unmarkIndex].markUndone(); + list[unmarkIndex].printMarkUndone(); + line = input.nextLine(); + break; - System.out.println("---------------------------------"); - System.out.println("Bye. Hope to see you again soon!"); + default: + list[matchCount] = new Task(line); + matchCount++; + printAction(line); + line = input.nextLine(); + break; + } + } + + System.out.println("---------------------------------"); + System.out.println("Bye. Hope to see you again soon!"); } } diff --git a/src/main/java/Task.java b/src/main/java/Task.java new file mode 100644 index 000000000..82efc6b1c --- /dev/null +++ b/src/main/java/Task.java @@ -0,0 +1,41 @@ +public class Task { + protected String description; + protected boolean isDone; + + public Task(String description) { // constructor of the task + this.description = description; + this.isDone = false; + } + + public String getStatusIcon() { + if (isDone) { + return "X"; + } + return " "; + } + + public String getDescription() { + return description; + } + + public void markDone(){ + isDone = true; + } + + public void markUndone(){ + isDone = false; + } + + public void printMarkDone() { + System.out.println("Good job on completing the task!"); + System.out.printf("[%s] %s\n", getStatusIcon(), description); + Siao.printDividerLine(); + } + + public void printMarkUndone() { + System.out.println("Okay we haven't finished it yet!"); + System.out.printf("[%s] %s\n", getStatusIcon(), description); + Siao.printDividerLine(); + } + +} From 15d4447439072310384c74219f943a76e42fa672 Mon Sep 17 00:00:00 2001 From: rsiowkf Date: Wed, 3 Sep 2025 22:41:42 +0800 Subject: [PATCH 12/12] level 4: Rough idea of labels only --- src/main/java/Siao.java | 40 +++++++++++++++++++++++++++++----------- src/main/java/Task.java | 8 +++++++- src/main/java/Todo.java | 26 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 src/main/java/Todo.java diff --git a/src/main/java/Siao.java b/src/main/java/Siao.java index a42499cb2..6f17832f8 100644 --- a/src/main/java/Siao.java +++ b/src/main/java/Siao.java @@ -3,6 +3,12 @@ public class Siao { + public enum Label{ + TODO, + EVENT, + DEADLINE + } + public static void printDividerLine(){ System.out.println("---------------------------------"); } @@ -10,24 +16,18 @@ public static void printDividerLine(){ public static void printList(Task[] list) { printDividerLine(); int indexNumber = 1; - for (int i = 0; i < list.length; i++) { - if(list[i] == null) { + for (Task task : list) { + if (task == null) { System.out.println("-----------End Of List-----------"); break; } - System.out.printf("%d. [%s] %s\n", indexNumber, list[i].getStatusIcon(), list[i].getDescription()); + System.out.printf("%d. [T][%s] %s\n", indexNumber, task.getStatusIcon(), task.getDescription()); indexNumber++; } printDividerLine(); } - public static void printAction(String action){ - printDividerLine(); - System.out.printf("added: " + action + "\n"); - printDividerLine(); - } - public static void main(String[] args) { System.out.println("Hello! I'm Siao!!"); @@ -43,12 +43,19 @@ public static void main(String[] args) { String command = splitInput[0]; switch (command){ - +// to add 3 more cases: TODO, EVENT and DEADLINE case "list": printList(list); line = input.nextLine(); break; + case "todo": + list[matchCount] = new Task(line); + matchCount++; + Todo.printAction(line); + line = input.nextLine(); + break; + case "mark": int markIndex = Integer.parseInt(splitInput[1]) - 1; list[markIndex].markDone(); @@ -66,7 +73,7 @@ public static void main(String[] args) { default: list[matchCount] = new Task(line); matchCount++; - printAction(line); + System.out.println(line); line = input.nextLine(); break; } @@ -76,3 +83,14 @@ public static void main(String[] args) { System.out.println("Bye. Hope to see you again soon!"); } } + +/* New Idea: +Everytime I input something, depending on the 1st word that I input, I will store the line into the task array +The task array will create a String +Each element in the String array will contain the following: + [Label of Task][Marker] "description" + + Task class will only contain information about the Mark and the description + my subclasses will contain information about the label + */ + diff --git a/src/main/java/Task.java b/src/main/java/Task.java index 82efc6b1c..29db34965 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -4,7 +4,7 @@ public class Task { public Task(String description) { // constructor of the task this.description = description; - this.isDone = false; + this.isDone = false; // to remove } public String getStatusIcon() { @@ -38,4 +38,10 @@ public void printMarkUndone() { Siao.printDividerLine(); } + public static void printAction(String action){ + Siao.printDividerLine(); + System.out.printf("added: " + action + "\n"); + Siao.printDividerLine(); + } + } diff --git a/src/main/java/Todo.java b/src/main/java/Todo.java new file mode 100644 index 000000000..1e1eb5578 --- /dev/null +++ b/src/main/java/Todo.java @@ -0,0 +1,26 @@ +public class Todo extends Task{ + + public Siao.Label taskType = Siao.Label.TODO; + + public Todo(String Description) { + super(Description); + isDone = false; + } + + public static String toDoLabel(){ + return "T"; + } + + public static void printAction(String action){ + Siao.printDividerLine(); + System.out.printf("Got it! Added this task in!\n [%s][ ] %s\n",toDoLabel(),action); + Siao.printDividerLine(); + } + + public void printMarkDone() { + System.out.println("Good job on completing the task!"); + System.out.printf("[%s][%s] %s\n",toDoLabel(), getStatusIcon(), description); + Siao.printDividerLine(); + } + +}