[Ege Demirkirkan] iP#71
Conversation
FTang21
left a comment
There was a problem hiding this comment.
Overall good job on following the coding standard
| @@ -0,0 +1,83 @@ | |||
| public class InputParser { | |||
| protected String[] args; | |||
| protected static String[] validCommands = {"mark", "m", "unmark", "um", "todo", "t", "deadline", "d", "event", "e", "list", "ls", "bye", "exit", "quit", "q"}; | |||
There was a problem hiding this comment.
I believe this is over 120 characters, perhaps make this into two separate lines?
| continue; | ||
| } | ||
| String command = parser.getPrefix(); | ||
| switch (command) { |
There was a problem hiding this comment.
Well done on the switch statement formatting!
| public class TaskManager { | ||
| ArrayList<Task> tasks; | ||
|
|
There was a problem hiding this comment.
Good: Plural form used to represent a collection of tasks. This is a common error that you avoided!
| @@ -0,0 +1,83 @@ | |||
| public class InputParser { | |||
| protected String[] args; | |||
| protected static String[] validCommands = {"mark", "m", "unmark", "um", "todo", "t", "deadline", "d", "event", "e", "list", "ls", "bye", "exit", "quit", "q"}; | |||
There was a problem hiding this comment.
Should use line wrapping instead, try to keep to a maximum of 120 characters per line.
Take note indentation for wrapped lines should be 8 spaces.
| switch (command) { | ||
| case "mark": | ||
| case "m": | ||
| manager.markTask(parser.getBody()); | ||
| break; | ||
| case "unmark": | ||
| case "um": | ||
| manager.unmarkTask(parser.getBody()); | ||
| break; | ||
| case "list": | ||
| case "ls": | ||
| manager.displayTaskList(); | ||
| break; | ||
| case "bye": | ||
| case "b": | ||
| case "quit": | ||
| case "q": | ||
| break label; | ||
| default: | ||
| manager.addTask(parser.getBody(), parser.getSuffix(), parser.getType()); | ||
| break; | ||
| } |
There was a problem hiding this comment.
Good: You indented the case statement correctly, this is a common mistake which you avoid.
| printWithSeparator("Nice! I've marked this task as done:", "\t[" + task.getStatusIcon() + "] " | ||
| + task.getDescription()); |
There was a problem hiding this comment.
Good use of line wrapping here so that code is kept within 120 characters per line.
Correct indentation of wrapped line too at 8 spaces.
xseh
left a comment
There was a problem hiding this comment.
Good attempt! Do take note of magic literals and some variable naming (especially when it comes to loops).
| public static void run(Scanner scanner, TaskManager manager) { | ||
| manager.welcomeUser(); | ||
| label: | ||
| while (true) { |
There was a problem hiding this comment.
Avoid magic booleans. Consider putting into variable (e.g. canContinue)
| manager.addTask(parser.getBody(), parser.getSuffix(), parser.getType()); | ||
| } catch (jrobo.exception.InvalidFormatException | jrobo.exception.InvalidTypeException e) { |
There was a problem hiding this comment.
Avoid complicated expressions. Consider refactoring the line into separator methods.
| } | ||
|
|
||
| public String getPrefix() { | ||
| for (String s : validCommands) { |
There was a problem hiding this comment.
Consider renaming the variable s in improve readability, such as command
|
|
||
| public String getSuffix() { | ||
| int suffixIndex = findSuffixIndex(); | ||
| if (suffixIndex == -1) { |
There was a problem hiding this comment.
Avoid magic numbers. Consider declaring a variable (e.g. INVALID_INDEX) for the integer -1 instead.
| if (!isDeadline && !isEvent && (getPrefix().equals("todo") || getPrefix().equals("t"))) { | ||
| return "todo"; | ||
| } | ||
| if (isDeadline && (getPrefix().equals("deadline") || getPrefix().equals("d"))) { | ||
| return "deadline"; | ||
| } | ||
| if (isEvent && (getPrefix().equals("event") || getPrefix().equals("e"))) { | ||
| return "event"; | ||
| } | ||
| throw new InvalidFormatException("Invalid command format!"); |
There was a problem hiding this comment.
Consider SLAPing more by refactoring the code into separate methods.
| int found = -1; | ||
| for (int i = 0; i < args.length; i++) { | ||
| String s = args[i]; | ||
| if (s.equals("/at") || s.equals("/by")) { |
There was a problem hiding this comment.
Avoid magic literals. Consider putting strings "/at" and "/by" into variables (e.g. COMMAND_AT and COMMAND_BY)
Branch level 7
add date capabilities
add find task command
No description provided.