[Moo Jun Wei] iP - #504
Conversation
alvinjiang1
left a comment
There was a problem hiding this comment.
Other than certain long methods and some small issues regarding coding standards, I think the code is fine. Keep up the good work! You are doing great :))
| @Override | ||
| public String toDataString() { | ||
| return String.format("[D] | %d | %s | %s", | ||
| isMarked() ? 1 : 0, |
There was a problem hiding this comment.
Perhaps you could look into replacing the 1 and 0 in the conditional statement with a named constant? It could be considered a "magic number".
| System.out.println( | ||
| "Hello! I'm Duke\n" + | ||
| "What can I do for you?" | ||
| ); |
There was a problem hiding this comment.
Could perhaps break up the line before the operator, in accordance with the coding standards?
| loop(sc); | ||
| } | ||
|
|
||
| public void loop(Scanner sc) { |
There was a problem hiding this comment.
This method looks long and complex, could think of abstracting out key components into different methods?
| import java.util.List; | ||
| import java.util.Scanner; | ||
|
|
||
| public class Duke { |
There was a problem hiding this comment.
It would be great if javadocs are included :))
Previously, the parse() method is lengthy. The body is divided into two main responsibilities - separating the input into the command keyword and the body, and then parsing them to return a Command. Code blocks are extracted into two private methods to improve the readability of the code and adhere to a single level\ of abstraction within parse().
Improve code quality in InputParser
Performing consecutive undos will undo commands one-by-one in order of the history of executed commands. Undo itself is not included in the history of executed commands.
Add ability to undo commands
| switch (command) { | ||
| case "bye": | ||
| return new ExitCommand(ui); | ||
| case "list": | ||
| return new PrintTasksCommand(ui, tasks); | ||
| case "mark": | ||
| return new MarkTaskCommand(storage, ui, tasks, body); | ||
| case "unmark": | ||
| return new UnmarkTaskCommand(storage, ui, tasks, body); | ||
| case "delete": | ||
| return new DeleteTaskCommand(storage, ui, tasks, body); | ||
| case "find": | ||
| return new FindTaskCommand(tasks, ui, body); | ||
| case "todo": | ||
| return new AddTaskCommand(storage, ui, tasks, TaskType.TODO, body); | ||
| case "deadline": | ||
| return new AddTaskCommand(storage, ui, tasks, TaskType.DEADLINE, body); | ||
| case "event": |
There was a problem hiding this comment.
I think this change(from if to swtich) is good!
Duke
Features
Downloads
Duke is FREE to download and use! (releases)
Quick Start
todo buy grocerieslistmark 1Implementation
Here's the main method:
To be Completed