[Liu Xuyan] iP#185
Conversation
|
|
||
| private static void markTask(int index) { | ||
| System.out.println("____________________________________________________________"); | ||
| if (index < 0 || index > taskCount) { |
There was a problem hiding this comment.
The condition should be index <= 0 || index > taskCount to properly handle cases where index = 0.
|
|
||
| @Override | ||
| public String toString() { | ||
| return "[E]" + super.toString() + " (from: " + from + " to: " + to + ")"; |
There was a problem hiding this comment.
Lack of spacing after "[E]" reduces readability.I think it's better if can add return "[E] " + super.toString() + " (from: " + from + " to: " + to + ")"; like this
| default: | ||
| repeat(command); | ||
| } | ||
| } |
There was a problem hiding this comment.
The class is well-structured with clear separation of concerns.
| @@ -0,0 +1,26 @@ | |||
| public class Task { | |||
| protected String taskName; | |||
| protected boolean isDone; | |||
|
|
||
| public void unmarkAsDone() { | ||
| this.isDone = false; | ||
| } |
There was a problem hiding this comment.
Can use a single setter public void setDone(boolean isDone) here
| @@ -0,0 +1,13 @@ | |||
| public class Deadline extends Task { | |||
| protected String deadLine; | |||
There was a problem hiding this comment.
Depends on how you view the word Deadline, but if this is one word, it should be all lowercase like deadline
| public class Flaaaash { | ||
| private static final int maxCount = 100; | ||
| private static final Task[] tasks = new Task[maxCount]; | ||
| private static int taskCount = 0; |
There was a problem hiding this comment.
Good naming standard for the tasks array
| public class Todo extends Task { | ||
| public Todo(String taskName) { | ||
| super(taskName); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "[T]" + super.toString(); | ||
| } | ||
| } |
|
|
||
| @Override | ||
| public String toString() { | ||
| return "[D]" + super.toString() + " (by: " + deadLine + ")"; |
There was a problem hiding this comment.
I noticed the same issue in several other places too as himethcodes mentioned(spacing)
| @@ -0,0 +1,13 @@ | |||
| public class Deadline extends Task { | |||
| protected String deadLine; | |||
There was a problem hiding this comment.
You can just name it deadline cause it is single word
| break; | ||
|
|
||
| case "deadline": | ||
| String[] deadlineInputDetails = inputParts[1].split(" /by ", 2); |
There was a problem hiding this comment.
You can handle with the error with splitting string
| private static final int maxCount = 100; | ||
| private static final Task[] tasks = new Task[maxCount]; |
There was a problem hiding this comment.
Avoiding the use of magic number very well
tongkiankiat
left a comment
There was a problem hiding this comment.
Code is well structured and neat, good job adding in switch case statements to introduce different methods for different inputs!
| greet(); | ||
| Scanner scanner = new Scanner(System.in); | ||
|
|
||
| while (true) { |
There was a problem hiding this comment.
Nice use of switch-case statements to avoid deep nesting!
| tasks[index - 1].markAsDone(); | ||
| System.out.println(" " + tasks[index - 1]); | ||
| } | ||
| System.out.println("____________________________________________________________"); |
There was a problem hiding this comment.
This magic string could be stored in a variable, since it is used multiple times
| } | ||
|
|
||
| private static void addTask(Task task) { | ||
| tasks[taskCount] = task; |
There was a problem hiding this comment.
Good naming convention for singular nouns and plural nouns.
| System.out.println("____________________________________________________________"); | ||
| System.out.println(" Got it. I've added this task:"); | ||
| System.out.println(" " + tasks[taskCount - 1]); | ||
| System.out.println(" Now you have " + taskCount + " tasks in the list."); |
There was a problem hiding this comment.
Could add in the different spelling for 'task' when there is only 1 task and when there are multiple tasks
| System.out.println(" " + tasks.get(index - 1)); | ||
| tasks.remove(tasks.get(index - 1)); | ||
| System.out.println(" Now you have " + tasks.size() + " tasks in the list."); | ||
| System.out.println("____________________________________________________________"); |
There was a problem hiding this comment.
Avoid repeating this code line. Store it in a variable or make it a function and use it multiple times.
| } | ||
| } | ||
|
|
||
| private static void loadFromFile() { |
There was a problem hiding this comment.
Keep the method length to about 30 lines of code
| try { | ||
| Scanner fileScanner = new Scanner(file); | ||
| while (fileScanner.hasNextLine()) { | ||
| String line = fileScanner.nextLine(); | ||
| String[] parts = line.split(" / "); | ||
|
|
||
| try { | ||
| String type = parts[0]; | ||
| boolean isDone = parts[1].equals("1"); | ||
| String description = parts[2]; | ||
|
|
||
| switch (type) { | ||
| case "T": |
There was a problem hiding this comment.
Avoid the arrow head style code
Create package for command, ui, parser, data, common, storage and exception.
Write MESSGAE_USAGE for all command subclasses.
Update relevant classes (HelpCommand, Parser) for newly added class.
Add FindCommand class.
…ial private methods.
Add header comments to most non-private classes/methods, and non-triv…
Improve the level of abstraction of Parser class
Add Task class to manage tasks.
Add addTask() method to add tasks.
Add List() method to allow users to view the stored tasks.
Add markTask() and unmarkTask() to manage the status of a task.