-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Cheah Hao Yi] iP #57
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I think it's quite good. Just need those minor edits that I suggested.
src/main/java/Duke.java
Outdated
public class Duke { | ||
public static void main(String[] args) { | ||
|
||
public static Task[] tasks = new Task[100]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace magic literal ('100'). Consider using a final value.
src/main/java/Duke.java
Outdated
public static Task[] tasks = new Task[100]; | ||
public static int numTasks = 0; | ||
|
||
public static void listTasks(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should be a space between the closing bracket and open brace. You can use the reformat code option for the IDE to do it for you
src/main/java/Duke.java
Outdated
System.out.println("What can I do for you?"); | ||
} | ||
|
||
public static boolean toExit(String userInput) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can consider changing the method name to reflect the boolean nature of the method (toExit does not sound like it's a boolean method)
src/main/java/Duke.java
Outdated
System.out.println("Beep boop, now you have " + numTasks + " tasks"); | ||
} | ||
|
||
public static void addDeadline(String param){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps it is accidental, but there are actually 2 spaces between 'public' and 'static' in this method and the next method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. Hope my review could help.
src/main/java/Duke.java
Outdated
public class Duke { | ||
public static void main(String[] args) { | ||
|
||
public static Task[] tasks = new Task[100]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using magic literals. Consider adding a constant for it.
src/main/java/Duke.java
Outdated
final String ERROR_OUT_OF_BOUND = "Sorry, the task does not seem to exist :<"; | ||
tasks[whichTask].setStatus(done); | ||
|
||
if(whichTask > numTasks){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding spaces before the opening parenthesis and after the closing parenthesis.
src/main/java/Duke.java
Outdated
System.out.println("Beep boop, now you have " + numTasks + " tasks"); | ||
} | ||
|
||
public static void addDeadline(String param){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid double spacing.
src/main/java/Duke.java
Outdated
*/ | ||
|
||
final String LOGO = "\n" + | ||
" _________________________________________\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation for wrapped lines should be 8 spaces.
src/main/java/Duke.java
Outdated
|
||
public static void listTasks(){ | ||
System.out.println("Beep beep, listing out the tasks....Loading....."); | ||
for(int i = 0; i < numTasks; i++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding space before the opening parenthesis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Over all great job, amazing code and very creative :)
src/main/java/Duke.java
Outdated
public class Duke { | ||
public static void main(String[] args) { | ||
|
||
public static Task[] tasks = new Task[100]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use magic number
src/main/java/Duke.java
Outdated
} | ||
|
||
public static void processUserInput(String userInput){ | ||
String[] splitInput = userInput.split(" ", 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of splitInput- inputSplitedBySpace
src/main/java/Task.java
Outdated
private boolean isDone; | ||
private String taskDescription; | ||
|
||
private final String STATUS_DONE_ICON = "X"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gread job! adding the final String for the mark status
src/main/java/Duke.java
Outdated
public static void main(String[] args) { | ||
|
||
public static Task[] tasks = new Task[100]; | ||
public static int numTasks = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to a more informative name
…ity to handle errors" This reverts commit 1f2180e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Hao Yi, good job on the iP so far! I have added some comments on the code quality, coding standard violations and naming conventions. Hope they will be helpful. 👍🏽
src/main/java/Duke/Duke.java
Outdated
|
||
public static void greetUser() { | ||
|
||
final String LOGO = "\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving the final
variable to make it a global variable in this class.
src/main/java/Duke/Duke.java
Outdated
System.out.println(LOGO); | ||
System.out.println("Hello! I'm Duke"); | ||
System.out.println("What can I do for you?"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps can avoid the usage of magic literals by declaring these as final
variables in this class. (Same for line 64)
src/main/java/Duke/Duke.java
Outdated
System.out.println("What can I do for you?"); | ||
} | ||
|
||
public static boolean isToExit(String userInput) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps name this function isExit
since it would be easier to understand at first glance.
src/main/java/Duke/InputParser.java
Outdated
case ("list"): //Fallthrough | ||
case ("mark"): //Fallthrough | ||
case ("unmark"): //Fallthrough | ||
case ("todo"): //Fallthrough | ||
case ("deadline"): //Fallthrough |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps remove the comment //Fallthrough
since it is redundant. You can consider adding one fallthrough comment at the end of the case. (I see this in a couple of places, so do look into that)
src/main/java/Duke/InputParser.java
Outdated
return false; | ||
} | ||
} | ||
private boolean isCorrectInput(String[] parsed ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding at least a single line space between functions to improve readability
src/main/java/Duke/InputParser.java
Outdated
} | ||
|
||
private String[] parseParameter(String inputString, String optionFlag){ | ||
int OPTION_LEN = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming conventions of regular variables is pascalCase. Consider using that here instead of all caps.
src/main/java/Duke/InputParser.java
Outdated
|
||
public void parseUserInput(String userInput) throws UnknownCommandException, DukeException { | ||
|
||
String[] inputSplitBySpace = userInput.split(" ", 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do consider avoiding the usage of magic literals. Store and use the values as final
variables instead
src/main/java/Duke/InputParser.java
Outdated
public void parseUserInput(String userInput) throws UnknownCommandException, DukeException { | ||
|
||
String[] inputSplitBySpace = userInput.split(" ", 2); | ||
//assume first word input by user is the command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bring this comment closer to right above the line it describes, so it is clear as to what you are talking about
src/main/java/Duke/TaskManager.java
Outdated
public class TaskManager { | ||
|
||
private static final int RESIZE_FACTOR = 2; | ||
private static int NUM_TASK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the naming conventions for regular variables. It should be pascalCase for this one since it is not a final
variable
# Conflicts: # src/main/java/Duke/InputParser.java
Create Jar file # Conflicts: # src/main/java/Duke/TaskManager.java
Add new exceptions Refactor Exception using Inheritance
Init class for Level 8
Refactor some functions from Duke class into utilities classes
Refactor functionalities more clearly into the utility classes
Add exception check for wrong option flag Add find functionality
Level 9, Week 7 iP task: Find
To push A-MoreOOP tag onto github (missed out earlier)
To create branch for A-JavaDoc (missed out earlier)
Fix minor coding style violations
Fix parser bug for bad option flags Refactor to replace hardcoded line seperator with java system line separator
Added week 3 iP progress