diff --git a/src/main/java/commands/AddCommand.java b/src/main/java/commands/AddCommand.java index f76d963375..d6964db058 100644 --- a/src/main/java/commands/AddCommand.java +++ b/src/main/java/commands/AddCommand.java @@ -35,7 +35,7 @@ public boolean isExit() { return false; } - public String addToDo(TaskList tasks, String input) throws WeiException { + private String addToDo(TaskList tasks, String input) throws WeiException { if (input.length() < 5) { throw new WeiException("please tell me what is your task about"); } @@ -43,7 +43,7 @@ public String addToDo(TaskList tasks, String input) throws WeiException { return tasks.add(todo); } - public String addDeadline(TaskList tasks, String input) throws WeiException { + private String addDeadline(TaskList tasks, String input) throws WeiException { try { int index = input.indexOf("/"); String task = input.substring(9, index - 1); @@ -56,7 +56,7 @@ public String addDeadline(TaskList tasks, String input) throws WeiException { } } - public String addEvent(TaskList tasks, String input) throws WeiException { + private String addEvent(TaskList tasks, String input) throws WeiException { try { int firstIndex = input.indexOf("/"); int secondIndex = input.lastIndexOf("/"); diff --git a/src/main/java/tasks/Deadline.java b/src/main/java/tasks/Deadline.java index 477a0b0c5b..596a541394 100644 --- a/src/main/java/tasks/Deadline.java +++ b/src/main/java/tasks/Deadline.java @@ -18,7 +18,7 @@ public Deadline(String task, String date, boolean status) { @Override public String stringify() { String formattedDate = this.date.format(DateTimeFormatter.ofPattern("MMM d yyyy")); - return "[D]" + super.stringify() + "(by: " + formattedDate + ")"; + return "[D]" + super.stringify() + " (by: " + formattedDate + ")"; } @Override diff --git a/src/main/java/ui/Ui.java b/src/main/java/ui/Ui.java index 48051d8b00..55a9a32742 100644 --- a/src/main/java/ui/Ui.java +++ b/src/main/java/ui/Ui.java @@ -2,7 +2,7 @@ public class Ui { public void showLine() { - System.out.println("______________________________"); + System.out.println("________________________________________"); } public void greet() { diff --git a/src/test/java/tasks/DeadlineTest.java b/src/test/java/tasks/DeadlineTest.java new file mode 100644 index 0000000000..ed6d39e7d6 --- /dev/null +++ b/src/test/java/tasks/DeadlineTest.java @@ -0,0 +1,25 @@ +package tasks; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class DeadlineTest { + @Test + public void testStringify_(){ + Deadline deadline = new Deadline("read book", "2024-02-03"); + assertEquals("[D][ ] read book (by: Feb 3 2024)", deadline.stringify()); + + Deadline markedDeadline = new Deadline("play", "2024-02-03", true); + assertEquals("[D][X] play (by: Feb 3 2024)", markedDeadline.stringify()); + } + + @Test + public void testToString(){ + Deadline deadline = new Deadline("read book", "2024-02-03"); + assertEquals("D | O | read book | 2024-02-03", deadline.toString()); + + Deadline markedDeadline = new Deadline("play", "2024-02-03", true); + assertEquals("D | X | play | 2024-02-03", markedDeadline.toString()); + } +} diff --git a/src/test/java/tasks/TodoTest.java b/src/test/java/tasks/TodoTest.java new file mode 100644 index 0000000000..9f6b4905dd --- /dev/null +++ b/src/test/java/tasks/TodoTest.java @@ -0,0 +1,25 @@ +package tasks; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class TodoTest { + @Test + public void testStringify_(){ + ToDo todo = new ToDo("read book"); + assertEquals("[T][ ] read book", todo.stringify()); + + ToDo markedTodo = new ToDo("play", true); + assertEquals("[T][X] play", markedTodo.stringify()); + } + + @Test + public void testToString(){ + ToDo todo = new ToDo("read book"); + assertEquals("T | O | read book", todo.toString()); + + ToDo markedTodo = new ToDo("play", true); + assertEquals("T | X | play", markedTodo.toString()); + } +}