diff --git a/src/main/java/Duke.java b/src/main/java/duke/Duke.java similarity index 95% rename from src/main/java/Duke.java rename to src/main/java/duke/Duke.java index 954b15d5a7..9783d30a18 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/duke/Duke.java @@ -1,3 +1,11 @@ +package duke; + +import duke.logic.*; +import duke.task.Deadline; +import duke.task.Event; +import duke.task.Task; +import duke.task.Todo; + import java.io.FileNotFoundException; import java.lang.reflect.Array; @@ -72,7 +80,7 @@ public void run() { } else { tasks.addTask(new Event(description, secondString)); } - } else {//all other keywords not part of Duke's task handling schedule + } else {//all other keywords not part of duke.Duke's duke.task handling schedule throw new DukeException(" OOPS!!! I'm sorry, but I don't know what that means :-("); } } catch (DukeException de) { diff --git a/src/main/java/DukeException.java b/src/main/java/duke/logic/DukeException.java similarity index 76% rename from src/main/java/DukeException.java rename to src/main/java/duke/logic/DukeException.java index 23aa21f647..d26968bc74 100644 --- a/src/main/java/DukeException.java +++ b/src/main/java/duke/logic/DukeException.java @@ -1,4 +1,4 @@ -import java.io.FileNotFoundException; +package duke.logic; public class DukeException extends Exception { public DukeException(String message) { diff --git a/src/main/java/Parser.java b/src/main/java/duke/logic/Parser.java similarity index 91% rename from src/main/java/Parser.java rename to src/main/java/duke/logic/Parser.java index 960c0ae1b0..5baa365ee9 100644 --- a/src/main/java/Parser.java +++ b/src/main/java/duke/logic/Parser.java @@ -1,3 +1,5 @@ +package duke.logic; + import java.lang.reflect.Array; public class Parser { @@ -14,7 +16,7 @@ public void parse() { //cannot use "|" as a replacement System.out.println(temp); String[] tempArr = temp.split(":"); command = (String)Array.get(tempArr, 0); - if(tempArr.length > 1) { //account for the fact that commands like "list" do not have task details + if(tempArr.length > 1) { //account for the fact that commands like "list" do not have duke.task details taskDetails = ((String) Array.get(tempArr, 1)).trim(); } } diff --git a/src/main/java/Storage.java b/src/main/java/duke/logic/Storage.java similarity index 96% rename from src/main/java/Storage.java rename to src/main/java/duke/logic/Storage.java index 7006fd1ba9..bfc408884e 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/duke/logic/Storage.java @@ -1,3 +1,10 @@ +package duke.logic; + +import duke.task.Deadline; +import duke.task.Event; +import duke.task.Task; +import duke.task.Todo; + import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; diff --git a/src/main/java/TaskList.java b/src/main/java/duke/logic/TaskList.java similarity index 73% rename from src/main/java/TaskList.java rename to src/main/java/duke/logic/TaskList.java index bfea35f496..1fc645eb1c 100644 --- a/src/main/java/TaskList.java +++ b/src/main/java/duke/logic/TaskList.java @@ -1,3 +1,7 @@ +package duke.logic; + +import duke.task.Task; + import java.util.ArrayList; /** @@ -33,9 +37,9 @@ public void printList() { } /** - * Sets a task in a specified position in listOfTasks as done. + * Sets a duke.task in a specified position in listOfTasks as done. * - * @param number Specified index of task.Task object in listOfTasks. + * @param number Specified index of duke.task.duke.task.Task object in listOfTasks. */ public void setTaskAsDone(int number) { Task temp = this.listOfTasks.get(number - 1); @@ -43,10 +47,10 @@ public void setTaskAsDone(int number) { } /** - * Returns a task.Task object in a specified position in listOfTasks. + * Returns a duke.task.duke.task.Task object in a specified position in listOfTasks. * - * @param number Specified index of task.Task object in listOfTasks. - * @return task.Task + * @param number Specified index of duke.task.duke.task.Task object in listOfTasks. + * @return duke.task.duke.task.Task */ public Task getTask(int number) { //what about case where it is empty? return this.listOfTasks.get(number); diff --git a/src/main/java/Ui.java b/src/main/java/duke/logic/Ui.java similarity index 84% rename from src/main/java/Ui.java rename to src/main/java/duke/logic/Ui.java index 04b118d415..3c78fef0ff 100644 --- a/src/main/java/Ui.java +++ b/src/main/java/duke/logic/Ui.java @@ -1,3 +1,7 @@ +package duke.logic; + +import duke.task.Task; + import java.util.Scanner; public class Ui { @@ -38,18 +42,18 @@ public void showWelcome() { + "| |_| | |_| | < __/\n" + "|____/ \\__,_|_|\\_\\___|\n"; System.out.println("Hello from\n" + logo); - System.out.println("Hello! I'm Duke\nWhat can I do for you?" ); + System.out.println("Hello! I'm duke.Duke\nWhat can I do for you?" ); } public void showDone(Task task) { this.showLine(); - System.out.println(" Nice! I've marked this task as done:"); + System.out.println(" Nice! I've marked this duke.task as done:"); System.out.println(" " + task); this.showLine(); this.separationline(); } public void showDelete(Task task, int size) { this.showLine(); - System.out.println(" Nice! I've removed this task:"); + System.out.println(" Nice! I've removed this duke.task:"); System.out.println(" " + task); System.out.println(" Now you have " + size + " tasks in the list."); this.showLine(); @@ -57,7 +61,7 @@ public void showDelete(Task task, int size) { } public void showAdd(Task task, int size) { this.showLine(); - System.out.println(" Got it. I've added this task:"); + System.out.println(" Got it. I've added this duke.task:"); System.out.println(" " + task); System.out.println(" Now you have " + size + " tasks in the list."); this.showLine(); diff --git a/src/main/java/Date.java b/src/main/java/duke/task/Date.java similarity index 98% rename from src/main/java/Date.java rename to src/main/java/duke/task/Date.java index f256d14406..c57742783f 100644 --- a/src/main/java/Date.java +++ b/src/main/java/duke/task/Date.java @@ -1,3 +1,5 @@ +package duke.task; + import java.lang.reflect.Array; public class Date { diff --git a/src/main/java/Deadline.java b/src/main/java/duke/task/Deadline.java similarity index 97% rename from src/main/java/Deadline.java rename to src/main/java/duke/task/Deadline.java index 1de4e3da0f..e07cd3cc03 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/duke/task/Deadline.java @@ -1,3 +1,5 @@ +package duke.task; + import java.lang.reflect.Array; public class Deadline extends Task { diff --git a/src/main/java/Event.java b/src/main/java/duke/task/Event.java similarity index 97% rename from src/main/java/Event.java rename to src/main/java/duke/task/Event.java index 88b464367e..e5bcb7a433 100644 --- a/src/main/java/Event.java +++ b/src/main/java/duke/task/Event.java @@ -1,3 +1,5 @@ +package duke.task; + import java.lang.reflect.Array; public class Event extends Task { diff --git a/src/main/java/Task.java b/src/main/java/duke/task/Task.java similarity index 97% rename from src/main/java/Task.java rename to src/main/java/duke/task/Task.java index 1e162aa871..6df4037362 100644 --- a/src/main/java/Task.java +++ b/src/main/java/duke/task/Task.java @@ -1,3 +1,5 @@ +package duke.task; + public class Task { private String description; public boolean done; diff --git a/src/main/java/Time.java b/src/main/java/duke/task/Time.java similarity index 93% rename from src/main/java/Time.java rename to src/main/java/duke/task/Time.java index b84df003e5..3508beb103 100644 --- a/src/main/java/Time.java +++ b/src/main/java/duke/task/Time.java @@ -1,3 +1,5 @@ +package duke.task; + public class Time { private int hour; private int minute; @@ -23,6 +25,7 @@ public String toString() { } else { timeString.append(this.hour); if (this.minute != 0) { + timeString.append(":"); timeString.append(this.minute); } timeString.append("am"); diff --git a/src/main/java/Todo.java b/src/main/java/duke/task/Todo.java similarity index 93% rename from src/main/java/Todo.java rename to src/main/java/duke/task/Todo.java index 0c53f6944d..71b8d3de31 100644 --- a/src/main/java/Todo.java +++ b/src/main/java/duke/task/Todo.java @@ -1,3 +1,5 @@ +package duke.task; + public class Todo extends Task { public Todo(String description) { diff --git a/src/test/java/duke/task/TaskTest.java b/src/test/java/duke/task/TaskTest.java new file mode 100644 index 0000000000..77bfec4afb --- /dev/null +++ b/src/test/java/duke/task/TaskTest.java @@ -0,0 +1,18 @@ + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import +public class TaskTest { + @Test + public void testStringConversion() { + Assertions.assertEquals("[T][✗] eat", new Todo("eat").toString()); + Assertions.assertEquals("[D][✗] read by: 6th September 2019, 740pm", new Deadline("read", "06/09/2019 1940"); + Assertions.assertEquals("[D][✗] meeting Jason at: 6th September 2019, 8:02pm", + new Event("meeting Jason", "06/09/2019 2002")); + } + public void testSetDone() { + Task temp = new Todo("sleep"); + temp.setDone(); + Assertions.assertEquals(done, temp.isDone()); + } +}