From d0c0974ce93b7b72140d6d09778677f7c5582240 Mon Sep 17 00:00:00 2001 From: sunxiuqi-stacked <59859941+sunxiuqi-stacked@users.noreply.github.com> Date: Mon, 31 Aug 2020 19:02:11 +0800 Subject: [PATCH 01/13] No changes --- 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 5d313334cc..7adf5b3b74 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -3,7 +3,7 @@ public static void main(String[] args) { String logo = " ____ _ \n" + "| _ \\ _ _| | _____ \n" + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" + + "| |_| | |_| \ < __/\n" + "|____/ \\__,_|_|\\_\\___|\n"; System.out.println("Hello from\n" + logo); } From 8197409a709c93b85f44681e6621158b58e5bb38 Mon Sep 17 00:00:00 2001 From: sunxiuqi-stacked <59859941+sunxiuqi-stacked@users.noreply.github.com> Date: Mon, 31 Aug 2020 19:06:23 +0800 Subject: [PATCH 02/13] First push --- src/main/java/Duke.java | 54 +++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 7adf5b3b74..6859852522 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,10 +1,50 @@ +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); + //Generates a greeting + greeting(); + request(); } -} + + public static void request(){ + Scanner in = new Scanner(System.in); + Task[] list = new Task[100]; + String line; + int i=0,j; + + while(true) { + String status ="[✗] "; + line = in.nextLine(); + + if (line.equals("bye")){ + System.out.println("Bye. Hope to see you again soon!"); + break; + }else if(line.equals("list")){ + for(j=0;j Date: Mon, 31 Aug 2020 19:07:05 +0800 Subject: [PATCH 03/13] First push --- src/main/java/Task.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/Task.java diff --git a/src/main/java/Task.java b/src/main/java/Task.java new file mode 100644 index 0000000000..24d31e35d9 --- /dev/null +++ b/src/main/java/Task.java @@ -0,0 +1,18 @@ +public class Task { + protected String description; + protected boolean isDone; + protected int listCount; + + + public Task(String description) { + this.description = description; + this.isDone = false; + this.listCount = 0; + } + + public int length() { + return listCount; //return tick or X symbols + } + + +} \ No newline at end of file From 9c97e2d8593f9d2d007562a2d17dcb3007f19ba8 Mon Sep 17 00:00:00 2001 From: sunxiuqi-stacked <59859941+sunxiuqi-stacked@users.noreply.github.com> Date: Mon, 31 Aug 2020 19:08:42 +0800 Subject: [PATCH 04/13] First push 2 --- src/main/java/Duke.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 6859852522..35dcd5c047 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -19,7 +19,9 @@ public static void request(){ line = in.nextLine(); if (line.equals("bye")){ - System.out.println("Bye. Hope to see you again soon!"); + System.out.println("____________________________________________________________\n" + +"Bye. Hope to see you again soon!\n" + +"____________________________________________________________\n"); break; }else if(line.equals("list")){ for(j=0;j Date: Sat, 5 Sep 2020 00:59:19 +0800 Subject: [PATCH 05/13] week 4 push --- src/main/java/Deadline.java | 14 +++++++++++++ src/main/java/Duke.java | 39 +++++++++++++++++++++++++++++++++---- src/main/java/Event.java | 14 +++++++++++++ src/main/java/Todo.java | 16 +++++++++++++++ 4 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 src/main/java/Deadline.java create mode 100644 src/main/java/Event.java create mode 100644 src/main/java/Todo.java diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java new file mode 100644 index 0000000000..3747b9d398 --- /dev/null +++ b/src/main/java/Deadline.java @@ -0,0 +1,14 @@ +public class Deadline extends Todo { + protected String by; + + public Deadline(String description, String by) { + super(description); + this.by = by; + } + public String getBy(){ + return by; + } + public void setBy(String by){ + this.by = by; + } +} \ No newline at end of file diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 35dcd5c047..199a45779f 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -13,7 +13,7 @@ public static void request(){ Task[] list = new Task[100]; String line; int i=0,j; - + int task_count = 0; while(true) { String status ="[✗] "; line = in.nextLine(); @@ -28,7 +28,9 @@ public static void request(){ if(list[j].isDone){ System.out.println((j+1)+ ". " + "[✓]" + list[j].description); }//not done - System.out.println((j+1)+ ". " + "[✗] " + list[j].description); + else { + System.out.println((j + 1) + ". " + "[✗] " + list[j].description); + } } }else if(line.contains("done")){ int num = Integer.parseInt(line.substring(5)); @@ -37,11 +39,40 @@ public static void request(){ System.out.println("____________________________________________________________\n"+ "Nice! I've marked this task as done:"); System.out.println("[✓] "+ list[num-1].description + "\n____________________________________________________________\n"); - } else { + }else if(line.contains("todo")){ + list[i] = new Todo(line); + System.out.println("____________________________________________________________\n"+ + "Got it. I've added this task: "); + task_count++; + System.out.println("[T][✗] "+ list[i].description); + System.out.println("Now you have "+ task_count +" tasks in the list."); + System.out.println("____________________________________________________________\n"); + i++; + }else if(line.contains("deadline")){ + String desc[] = line.split("/by"); + list[i] = new Deadline(desc[0],desc[1]); + System.out.println("____________________________________________________________\n"+ + "Got it. I've added this task: "); + task_count++; + System.out.println("[D][✗] "+ list[i].description + "(by:" + desc[1] +")"); + System.out.println("Now you have "+ task_count +" tasks in the list."); + System.out.println("____________________________________________________________\n"); + i++; + }else if(line.contains("event")){ + String desc[] = line.split("/at"); + list[i] = new Deadline(desc[0],desc[1]); + System.out.println("____________________________________________________________\n"+ + "Got it. I've added this task: "); + task_count++; + System.out.println("[E][✗] "+ list[i].description + "(at:" + desc[1] +")"); + System.out.println("Now you have "+ task_count +" tasks in the list."); + System.out.println("____________________________________________________________\n"); + i++; + }else { list[i] = new Task(line); System.out.println("____________________________________________________________"); System.out.println("added: "+ line); - System.out.println("____-________________________________________________________"); + System.out.println("_____________________________________________________________"); i++; } } diff --git a/src/main/java/Event.java b/src/main/java/Event.java new file mode 100644 index 0000000000..4bfa2e8c2c --- /dev/null +++ b/src/main/java/Event.java @@ -0,0 +1,14 @@ +public class Event extends Task { + protected String when; + public Event(String description, String when) { + super(description); + this.when = when; + } + + public String getWhen(){ + return when; + } + public void setWhen(String when){ + this.when = when; + } +} diff --git a/src/main/java/Todo.java b/src/main/java/Todo.java new file mode 100644 index 0000000000..30c8f69109 --- /dev/null +++ b/src/main/java/Todo.java @@ -0,0 +1,16 @@ +public class Todo extends Task { + protected boolean isDone; + + public Todo(String description) { + super(description); + isDone = false; + } + + public boolean isDone(){ + return isDone; + } + + public void setDone(boolean Done){ + this.isDone = Done; + } +} From 306e8bb68085ad8690ed9672b23ff25beb1a0c58 Mon Sep 17 00:00:00 2001 From: sunxiuqi-stacked <59859941+sunxiuqi-stacked@users.noreply.github.com> Date: Mon, 14 Sep 2020 23:24:58 +0800 Subject: [PATCH 06/13] Packages added --- src/main/duke/Duke.java | 115 +++++++++++++++++++++++++++++++ src/main/duke/task/Deadline.java | 15 ++++ src/main/duke/task/Event.java | 15 ++++ src/main/duke/task/Task.java | 19 +++++ src/main/duke/task/Todo.java | 17 +++++ 5 files changed, 181 insertions(+) create mode 100644 src/main/duke/Duke.java create mode 100644 src/main/duke/task/Deadline.java create mode 100644 src/main/duke/task/Event.java create mode 100644 src/main/duke/task/Task.java create mode 100644 src/main/duke/task/Todo.java diff --git a/src/main/duke/Duke.java b/src/main/duke/Duke.java new file mode 100644 index 0000000000..a65f4c979d --- /dev/null +++ b/src/main/duke/Duke.java @@ -0,0 +1,115 @@ +package main.duke; +import java.util.Scanner; + + +public class Duke { + public static void main(String[] args) { + //Generates a greeting + greeting(); + request(); + } + + public static void request(){ + Scanner in = new Scanner(System.in); + Task[] list = new Task[100]; + String line; + int i=0,j; + int task_count = 0; + while(true) { + String status ="[✗] "; + line = in.nextLine(); + + if (line.equals("bye")){ + System.out.println("____________________________________________________________\n" + +"Bye. Hope to see you again soon!\n" + +"____________________________________________________________\n"); + break; + }else if(line.equals("list")){ + for(j=0;j Date: Sun, 20 Sep 2020 14:32:51 +0800 Subject: [PATCH 07/13] week 6 push --- data/duke.txt | 1 + src/main/java/Deadline.class | Bin 0 -> 426 bytes src/main/java/Deadline.java | 1 + src/main/java/Duke.class | Bin 0 -> 4353 bytes src/main/java/Duke.java | 202 ++++++++++++++++++++++++++++------- src/main/java/Task.class | Bin 0 -> 413 bytes src/main/java/Todo.class | Bin 0 -> 347 bytes 7 files changed, 168 insertions(+), 36 deletions(-) create mode 100644 data/duke.txt create mode 100644 src/main/java/Deadline.class create mode 100644 src/main/java/Duke.class create mode 100644 src/main/java/Task.class create mode 100644 src/main/java/Todo.class diff --git a/data/duke.txt b/data/duke.txt new file mode 100644 index 0000000000..cde2f8b626 --- /dev/null +++ b/data/duke.txt @@ -0,0 +1 @@ +1. [E][✗] event AS (at: 16) diff --git a/src/main/java/Deadline.class b/src/main/java/Deadline.class new file mode 100644 index 0000000000000000000000000000000000000000..df69a60f7b897d73861041c2e2b4ed5b005a1f7a GIT binary patch literal 426 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 literal 0 HcmV?d00001 diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 199a45779f..69f0de4018 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,5 +1,8 @@ -import java.util.Scanner; - +//import java.util.Scanner; +import java.util.*; +import java.io.File; // Import the File class +import java.io.FileWriter; +import java.io.IOException; // Import the IOException class to handle errors public class Duke { public static void main(String[] args) { @@ -10,7 +13,7 @@ public static void main(String[] args) { public static void request(){ Scanner in = new Scanner(System.in); - Task[] list = new Task[100]; + List list = new ArrayList(); String line; int i=0,j; int task_count = 0; @@ -24,56 +27,139 @@ public static void request(){ +"____________________________________________________________\n"); break; }else if(line.equals("list")){ + System.out.println(" ____________________________________________________________\n" + + "Here are the tasks in your list: "); for(j=0;j list, int i){ + try { + File myObj = new File("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); + if (myObj.createNewFile()) { + System.out.println("File created!"); + } else { + System.out.println("File already exists."); + } + } catch (IOException e) { + System.out.println("An error occurred."); + e.printStackTrace(); + } + try { + FileWriter myWriter = new FileWriter("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); + for(int j=0;jMsn zTWArSMCQdXT`3+(SA=%=f1BQvM-I~klWQZX#P#Z7CbCI1OBk^eq2l7M)X98zoUXFD zxRg5QXq_io7LItP!MmHV^bY*9w64;#5cUR$kI`n^;b_3Iu5X2JpzwH&YG|&psZHaB ual$s+4l@A0qrMNn04}fPadrp0Kb;QQ6IWHjS2Uh~sdfnlZ1)&5u>TF}i9>Jz literal 0 HcmV?d00001 diff --git a/src/main/java/Todo.class b/src/main/java/Todo.class new file mode 100644 index 0000000000000000000000000000000000000000..bf38274315a72613cf0b355fb9c1d68affec5cbc GIT binary patch literal 347 zcmY*V%SyvQ6g`uq8S}99xe^z;N>Z?UEp8N7#Z5~W-KBOYqcwpf^{cumD1r+=z>gBo ztwnHi=ggefWxl>YJ^@_fD1-x7!;8^^ui%aH`boj>+rl>23dhOdF@MQ>i@cckhD~LQ z`Bgd&u!BG&j1eIgQ#mVXvh{6Q7zH)q+f6wm>tDIMqA4nI5j7cYM&C9O^90kMO_ALvak^8f$< literal 0 HcmV?d00001 From 486f88e7900ba6c9723602f341648f4b00358da0 Mon Sep 17 00:00:00 2001 From: HELIOS Date: Thu, 1 Oct 2020 13:17:04 +0800 Subject: [PATCH 08/13] Level 9 --- src/main/java/Duke.java | 266 ++++++++++-------------------------- src/main/java/Parser.java | 13 ++ src/main/java/Storage.java | 129 +++++++++++++++++ src/main/java/Task.java | 4 +- src/main/java/TaskList.java | 159 +++++++++++++++++++++ src/main/java/Ui.java | 31 +++++ 6 files changed, 409 insertions(+), 193 deletions(-) create mode 100644 src/main/java/Parser.java create mode 100644 src/main/java/Storage.java create mode 100644 src/main/java/TaskList.java create mode 100644 src/main/java/Ui.java diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 69f0de4018..b53cb616ac 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -4,216 +4,98 @@ import java.io.FileWriter; import java.io.IOException; // Import the IOException class to handle errors +import java.util.Scanner; + public class Duke { + public static String PATH = "C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"; + private static Storage storage = new Storage(); + private static TaskList tasks = new TaskList(); + private static Ui ui = new Ui(); + private static Parser parser = new Parser(); + + public Duke() { + } + public static void main(String[] args) { - //Generates a greeting - greeting(); + Ui.greeting(); + tasks = new TaskList(storage.readFile()); + TaskList.task_count = 0; request(); } - public static void request(){ + public static void request() { Scanner in = new Scanner(System.in); - List list = new ArrayList(); - String line; - int i=0,j; - int task_count = 0; + int i = 0; + while(true) { - String status ="[✗] "; - line = in.nextLine(); + String status = "[✗] "; + String line = in.nextLine(); + if (line.equals("bye")) { + ui.bye(); + return; + } - if (line.equals("bye")){ - System.out.println("____________________________________________________________\n" - +"Bye. Hope to see you again soon!\n" - +"____________________________________________________________\n"); - break; - }else if(line.equals("list")){ - System.out.println(" ____________________________________________________________\n" - + "Here are the tasks in your list: "); - for(j=0;j list, int i){ - try { - File myObj = new File("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); - if (myObj.createNewFile()) { - System.out.println("File created!"); - } else { - System.out.println("File already exists."); - } - } catch (IOException e) { - System.out.println("An error occurred."); - e.printStackTrace(); - } - try { - FileWriter myWriter = new FileWriter("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); - for(int j=0;j list, int i) { + try { + File myObj = new File("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); + if (myObj.createNewFile()) { + System.out.println("File created!"); + } else { + System.out.println("File already exists."); + } + } catch (IOException var7) { + System.out.println("An error occurred."); + var7.printStackTrace(); + } + + try { + FileWriter myWriter = new FileWriter("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); + + for(int j = 0; j < i; ++j) { + String timing = ""; + Object var10000; + String classtype; + if (list.get(j) instanceof Deadline) { + classtype = "[D]"; + var10000 = list.get(j); + timing = "(by: " + ((Deadline)var10000).getBy() + ")"; + } else if (list.get(j) instanceof Todo) { + classtype = "[T]"; + } else if (list.get(j) instanceof Event) { + classtype = "[E]"; + var10000 = list.get(j); + timing = "(at: " + ((Event)var10000).getWhen() + ")"; + } else { + classtype = "task"; + } + + if (((Task)list.get(j)).isDone) { + myWriter.write(j + 1 + ". " + classtype + " [✓] " + ((Task)list.get(j)).description + " " + timing + "\n"); + } else { + myWriter.write(j + 1 + ". " + classtype + " [X] " + ((Task)list.get(j)).description + " " + timing + "\n"); + } + } + + myWriter.close(); + System.out.println("Successfully saved to the file."); + } catch (IOException var8) { + System.out.println("An error occurred."); + var8.printStackTrace(); + } + + } + + public File checkFileExists(String filePath) throws IOException { + File dataFile = new File(filePath); + if (!dataFile.exists()) { + dataFile.createNewFile(); + } + + return dataFile; + } + + public List readFile() { + ArrayList taskList = new ArrayList(); + + try { + File dataFile = this.checkFileExists("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); + Scanner in = new Scanner(dataFile); + + while(in.hasNext()) { + String line = in.nextLine(); + String[] taskDetails = line.split(" "); + String var6 = taskDetails[1]; + byte var7 = -1; + switch(var6.hashCode()) { + case 89652: + if (var6.equals("[D]")) { + var7 = 1; + } + break; + case 89683: + if (var6.equals("[E]")) { + var7 = 2; + } + break; + case 90148: + if (var6.equals("[T]")) { + var7 = 0; + } + } + + switch(var7) { + case 0: + taskList.add(new Todo(taskDetails[3])); + break; + case 1: + taskList.add(new Deadline(taskDetails[3], taskDetails[4])); + break; + case 2: + taskList.add(new Event(taskDetails[3], taskDetails[4])); + break; + default: + taskList.add(new Task(taskDetails[3])); + } + + if (taskDetails[2].equals("[✓]")) { + int taskIndex = taskList.size() - 1; + ((Task)taskList.get(taskIndex)).markAsDone(); + } + } + } catch (IOException e) { + } + + return taskList; + } +} \ No newline at end of file diff --git a/src/main/java/Task.java b/src/main/java/Task.java index 24d31e35d9..7cbfb4fc1e 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -13,6 +13,8 @@ public Task(String description) { public int length() { return listCount; //return tick or X symbols } - + public void markAsDone(){ + this.isDone = true; + } } \ No newline at end of file diff --git a/src/main/java/TaskList.java b/src/main/java/TaskList.java new file mode 100644 index 0000000000..af3a303cb9 --- /dev/null +++ b/src/main/java/TaskList.java @@ -0,0 +1,159 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +import java.util.*; + +public class TaskList { + public static List list; + public static int task_count; + + public TaskList() { + list = new ArrayList(); + task_count = 0; + } + + public TaskList(List list) { + TaskList.list = list; + task_count = list.size(); + } + + public void printList(int i) { + for(int j = 0; j < i; ++j) { + String timing = ""; + String classtype; + if (list.get(j) instanceof Deadline) { + classtype = "[D]"; + timing = "(by: " + ((Deadline)list.get(j)).getBy() + ")"; + } else if (list.get(j) instanceof Todo) { + classtype = "[T]"; + } else if (list.get(j) instanceof Event) { + classtype = "[E]"; + timing = "(at: " + ((Event)list.get(j)).getWhen() + ")"; + } else { + classtype = "[T]"; + } + + if (((Task)list.get(j)).isDone) { + System.out.println(j + 1 + ". " + classtype + "[✓]" + ((Task)list.get(j)).description + timing); + } else { + System.out.println(j + 1 + ". " + classtype + "[✗] " + ((Task)list.get(j)).description + timing); + } + } + + } + + public static void printList(List list) { + for(int j=0;j returnList() { + return list; + } + + public static void Find(String description) { + List returnList = new ArrayList(); + System.out.println(" Here are the matching tasks in your list: "); + + for(int i = 0; i < list.size(); ++i) { + Task task = (Task)list.get(i); + if (task.description.contains(description)) { + returnList.add(i, (Task)list.get(i)); + } + } + + printList(returnList); + } +} \ No newline at end of file diff --git a/src/main/java/Ui.java b/src/main/java/Ui.java new file mode 100644 index 0000000000..1d5506461e --- /dev/null +++ b/src/main/java/Ui.java @@ -0,0 +1,31 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +public class Ui { + public Ui() { + } + + public void bye() { + System.out.println("____________________________________________________________\nBye. Hope to see you again soon!\n____________________________________________________________\n"); + } + + public void oops(String desc) { + System.out.println("____________________________________________________________\n☹ OOPS!!! The description of a " + desc + " cannot be empty."); + System.out.println("____________________________________________________________\n"); + } + + public void dunno() { + System.out.println("____________________________________________________________"); + System.out.println(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-( "); + System.out.println("_____________________________________________________________"); + } + + public static void greeting() { + System.out.println("____________________________________________________________"); + System.out.println("Hello! I'm Duke"); + System.out.println("What can I do for you?"); + System.out.println("____________________________________________________________"); + } +} From 5b5ce637ff84e53de81d5b7a3f75fa08192fdb46 Mon Sep 17 00:00:00 2001 From: HELIOS Date: Thu, 1 Oct 2020 14:04:06 +0800 Subject: [PATCH 09/13] A-JavaDoc --- src/main/java/Duke.java | 1 + src/main/java/Storage.java | 4 ++-- src/main/java/TaskList.java | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index b53cb616ac..155d7afc9a 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -6,6 +6,7 @@ import java.util.Scanner; +//main class public class Duke { public static String PATH = "C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"; private static Storage storage = new Storage(); diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index e00349857b..a917905a55 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -13,7 +13,7 @@ public class Storage { public Storage() { } - + //write to file public void writetofile(List list, int i) { try { File myObj = new File("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); @@ -72,7 +72,7 @@ public File checkFileExists(String filePath) throws IOException { return dataFile; } - + //read file public List readFile() { ArrayList taskList = new ArrayList(); diff --git a/src/main/java/TaskList.java b/src/main/java/TaskList.java index af3a303cb9..40f6822d8d 100644 --- a/src/main/java/TaskList.java +++ b/src/main/java/TaskList.java @@ -9,6 +9,7 @@ public class TaskList { public static List list; public static int task_count; + //tasks init public TaskList() { list = new ArrayList(); task_count = 0; @@ -19,6 +20,7 @@ public TaskList(List list) { task_count = list.size(); } + //2 printlist methods public void printList(int i) { for(int j = 0; j < i; ++j) { String timing = ""; @@ -78,6 +80,7 @@ public void markDone(int num) { System.out.println("[✓] " + ((Task)list.get(num - 1)).description + "\n____________________________________________________________\n"); } + //add task methods public static void addTodo(String[] desc, int i) { list.add(i, new Todo(desc[0])); System.out.println("____________________________________________________________\nGot it. I've added this task: "); From f54ecdb13759a436492947129a8df3c74ba0830c Mon Sep 17 00:00:00 2001 From: HELIOS Date: Thu, 1 Oct 2020 17:55:55 +0800 Subject: [PATCH 10/13] A-UserGuide --- docs/README.md | 162 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 155 insertions(+), 7 deletions(-) diff --git a/docs/README.md b/docs/README.md index fd44069597..ef257061a2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,19 +2,167 @@ ## Features -### Feature 1 -Description of feature. +### 1. Add Todo +Add a todo task to your task list. + +### 2. Add Deadline +Add a deadline to your task list. + +### 3. Add Event +Add an event to your task list. + +### 4. Mark task as Done +Mark a task in your task list as done. + +### 5. List all tasks +List all tasks in your task list. + +### 6. Delete task +Delete a task from your task list. + +### 7. Find task +Find tasks containing a keyword. + +### 8. Save task list +Save your task list to a .txt file. ## Usage -### `Keyword` - Describe action +### `todo ` - Add a Todo task + +Add a Todo task to your task list. + +Example of usage: + +`todo read book` + +Expected outcome: + +`____________________________________________________________ +Got it. I've added this task: ` +`[T][✗] read book` +`Now you have 1 tasks in the list.` +`____________________________________________________________` + +### `deadline /by ` - Add a Deadline + +Add a Deadline task to your task list. + +Example of usage: + +`deadline return book /by Monday` + +Expected outcome: + +`____________________________________________________________ +Got it. I've added this task: ` +`[T][✗] return book (by: Monday)` +`Now you have 2 tasks in the list.` +`____________________________________________________________` + +### `deadline /by ` - Add a Deadline + +Add a Deadline task to your task list. + +Example of usage: + +`deadline return book /by Monday` + +Expected outcome: + +`____________________________________________________________ +Got it. I've added this task: ` +`[T][✗] return book (by: Monday)` +`Now you have 2 tasks in the list.` +`____________________________________________________________` + +### `event /at ` - Add an Event + +Add an Event task to your task list. + +Example of usage: + +`event book fair /at 5pm Tuesday` + +Expected outcome: + +`____________________________________________________________ +Got it. I've added this task: ` +`[E][✘] book fair (at: 5pm Tuesday)` +`Now you have 3 tasks in the list.` +`____________________________________________________________` + +### `done ` - Mark task as done + +Mark a task in your task list as done. + +Example of usage: + +`done 1` + +Expected outcome: + +`____________________________________________________________ +Nice! I've marked this task as done: ` +`[[T][✓] read book` +`____________________________________________________________` + +### `list` - List all tasks + +List all tasks in your task list. + +Example of usage: + +`list` + +Expected outcome: + +`____________________________________________________________ +Here are the tasks in your list: ` +`1. [T][✓] read book` +`2. [D][✘] return book (by: Monday)` +`3. [E][✘] book fair (at: 5pm Tuesday)` +`____________________________________________________________` -Describe action and its outcome. +### `delete ` - Delete a task + +Delete a task from your task list. -Example of usage: +Example of usage: -`keyword (optional arguments)` +`delete 1` Expected outcome: -`outcome` +`____________________________________________________________` +`Removed: [T][✓] read book` +`Now you have 2 task(s) in your list` +`____________________________________________________________` + +### `find ` - Find tasks + +Find tasks with matching keyword. + +Example of usage: + +`find book` + +Expected outcome: + + +`Here are the matching tasks in your list: ` +`1. [D][✘] return book (by: Monday)` +`2. [E][✘] book fair (at: 5pm Tuesday)` + +### `save` - Save task list + +Save task list to .txt file. + +Example of usage: + +`save` + +Expected outcome: + + `Successfully saved to file!` + From 44ca7ce111b6b4ebc603b43304446216c8b23f5c Mon Sep 17 00:00:00 2001 From: HELIOS Date: Fri, 2 Oct 2020 01:29:12 +0800 Subject: [PATCH 11/13] A-UserGuide --- docs/README.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/docs/README.md b/docs/README.md index ef257061a2..dfc47a5490 100644 --- a/docs/README.md +++ b/docs/README.md @@ -56,23 +56,7 @@ Expected outcome: `____________________________________________________________ Got it. I've added this task: ` -`[T][✗] return book (by: Monday)` -`Now you have 2 tasks in the list.` -`____________________________________________________________` - -### `deadline /by ` - Add a Deadline - -Add a Deadline task to your task list. - -Example of usage: - -`deadline return book /by Monday` - -Expected outcome: - -`____________________________________________________________ -Got it. I've added this task: ` -`[T][✗] return book (by: Monday)` +`[D][✗] return book (by: Monday)` `Now you have 2 tasks in the list.` `____________________________________________________________` From 5286a049d65c829355f3c4877157aa2012837c20 Mon Sep 17 00:00:00 2001 From: HELIOS Date: Fri, 2 Oct 2020 09:45:15 +0800 Subject: [PATCH 12/13] A-UserGuide --- src/main/java/Storage.java | 10 ++++++++-- src/main/java/TaskList.java | 26 ++++++++++++++++++++++++-- src/main/java/Ui.java | 18 +++++++++++++++++- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index a917905a55..bedd15786b 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -13,7 +13,10 @@ public class Storage { public Storage() { } - //write to file + /** + * write to file + * ... + */ public void writetofile(List list, int i) { try { File myObj = new File("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); @@ -72,7 +75,10 @@ public File checkFileExists(String filePath) throws IOException { return dataFile; } - //read file + /** + * generate list from file + * ... + */ public List readFile() { ArrayList taskList = new ArrayList(); diff --git a/src/main/java/TaskList.java b/src/main/java/TaskList.java index 40f6822d8d..dc9bfe16ad 100644 --- a/src/main/java/TaskList.java +++ b/src/main/java/TaskList.java @@ -20,7 +20,10 @@ public TaskList(List list) { task_count = list.size(); } - //2 printlist methods + /** + * print list values based on integer i + * ... + */ public void printList(int i) { for(int j = 0; j < i; ++j) { String timing = ""; @@ -46,6 +49,10 @@ public void printList(int i) { } + /** + * print list values based on list + * ... + */ public static void printList(List list) { for(int j=0;j returnList() { return list; } + /** + * find matching tasks in list + * + */ public static void Find(String description) { List returnList = new ArrayList(); System.out.println(" Here are the matching tasks in your list: "); diff --git a/src/main/java/Ui.java b/src/main/java/Ui.java index 1d5506461e..ef3a5e033b 100644 --- a/src/main/java/Ui.java +++ b/src/main/java/Ui.java @@ -6,22 +6,38 @@ public class Ui { public Ui() { } - + /** + * bye msg + * ... + */ public void bye() { System.out.println("____________________________________________________________\nBye. Hope to see you again soon!\n____________________________________________________________\n"); } + /** + * error message + * ... + */ public void oops(String desc) { System.out.println("____________________________________________________________\n☹ OOPS!!! The description of a " + desc + " cannot be empty."); System.out.println("____________________________________________________________\n"); } + /** + * error message 2 + * ... + */ public void dunno() { System.out.println("____________________________________________________________"); System.out.println(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-( "); System.out.println("_____________________________________________________________"); } + /** + * greeting message + * + * ... + */ public static void greeting() { System.out.println("____________________________________________________________"); System.out.println("Hello! I'm Duke"); From c5c15b02029c7a946e3104bb40800baa222e820f Mon Sep 17 00:00:00 2001 From: HELIOS Date: Fri, 2 Oct 2020 17:02:58 +0800 Subject: [PATCH 13/13] A-Finally --- src/main/java/Storage.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index bedd15786b..039c82beb0 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -19,7 +19,7 @@ public Storage() { */ public void writetofile(List list, int i) { try { - File myObj = new File("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); + File myObj = new File("..\\..\\..\\..\\ip\\data\\duke.txt"); if (myObj.createNewFile()) { System.out.println("File created!"); } else { @@ -31,7 +31,7 @@ public void writetofile(List list, int i) { } try { - FileWriter myWriter = new FileWriter("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); + FileWriter myWriter = new FileWriter("..\\..\\..\\..\\ip\\data\\duke.txt"); for(int j = 0; j < i; ++j) { String timing = ""; @@ -83,7 +83,7 @@ public List readFile() { ArrayList taskList = new ArrayList(); try { - File dataFile = this.checkFileExists("C:\\Users\\HELIOS\\Downloads\\STUDY MATERIALS\\AY2021_SEM1\\CS2113\\Individualproject\\ip\\data\\duke.txt"); + File dataFile = this.checkFileExists("..\\..\\..\\..\\ip\\data\\duke.txt"); Scanner in = new Scanner(dataFile); while(in.hasNext()) {