[Chen Shun] IP - #491
Conversation
| private String line = "___________________________________________________"; | ||
| private String exit = "Bye. Hope to see you again soon!"; | ||
| Scanner sc = new Scanner(System.in); | ||
| ArrayList<Task> tasks; |
There was a problem hiding this comment.
Should tasks be private instead of public ?
| } | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
I like where you have multiple exceptions to account for different errors.
| } | ||
|
|
||
| private String getStatusIcon() { | ||
| return (isDone ? "[X]" : "[ ]"); // mark done task with X |
There was a problem hiding this comment.
Perhaps you can move the comment to the top.
| return this.getStatusIcon() + " " + this.description; | ||
| } | ||
|
|
||
| //... |
| @@ -0,0 +1,12 @@ | |||
| public class ToDo extends Task { | |||
|
|
|||
There was a problem hiding this comment.
Extra line break here, should this be removed?
| } else { | ||
| System.out.println("Here are the tasks in your list:"); | ||
| for (int i = 0; i < this.tasks.size(); i++) { | ||
| int sn = i + 1; |
There was a problem hiding this comment.
Maybe a intuitive name for variable sn?
| myPony.initialise(); | ||
| myPony.run(); | ||
| } | ||
| } |
There was a problem hiding this comment.
I like where you throw exceptions for each commands and how you added comments for each command which made reading your code easier.
| @@ -0,0 +1,195 @@ | |||
| import java.util.Scanner; | |||
| import java.util.ArrayList; | |||
| public class Pony { | |||
There was a problem hiding this comment.
Perhaps a line break to separate line 2 and line 3?
| @@ -0,0 +1,33 @@ | |||
| import java.lang.RuntimeException; | |||
| public class PonyException { | |||
There was a problem hiding this comment.
Maybe a line break to separate both lines?
april-anh
left a comment
There was a problem hiding this comment.
Detailed comments make your code very easy to understand.
| run(); | ||
| } | ||
| } else if (action.equals("todo")) { | ||
| // tod0 expects task description in command[1] |
There was a problem hiding this comment.
You can use "to-do" to prevent the text to be marked green.
| private void processCommand(String[] command) { | ||
| int commandSize = command.length; | ||
| String action = command[0]; | ||
| if (action.equals("list")) { |
There was a problem hiding this comment.
Maybe using switch instead of if-else can make your code neater?
| } catch (NumberFormatException e) { | ||
| System.out.println(new PonyException.taskInputError().getMessage()); | ||
| } finally { | ||
| run(); |
There was a problem hiding this comment.
I like how you carefully clean up your program after handling exceptions. 👍
tensaida
left a comment
There was a problem hiding this comment.
Good job! All the best for the upcoming weeks
| } | ||
|
|
||
| //Task to mark not provided | ||
| public static class taskMissingError extends RuntimeException { |
There was a problem hiding this comment.
You could make these Errors extend PonyException instead
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| Pony myPony = new Pony(); |
There was a problem hiding this comment.
Since only one Pony object is created, why not make everything static instead?
| run(); | ||
| } | ||
| } else if (action.equals("unmark")) { | ||
| // unmark expects input in command[1] -> which task to unmark |
Add assertions
Improve code quality
Response from pony is not friendly to user. Change some of the pony's response to a more friendly tone.
Find command is case sensitive. A case insensitive find is more user-friendly because users cannot be expected to remember the exact case of the keywords. Let's update the search algorithm by converting all strings to lowercase and find matches in lowercase.
DukePro
DukePro frees your mind of having to remember things you need to do. It's,
FASTSUPER FAST to useAll you need to do is,
And it is FREE!
Features: