-
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
[Sim Qian Hui] iP #58
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.
Good coding practices, only a few minor naming issues
src/main/java/Duke.java
Outdated
printAddItemText(newTodo); | ||
break; | ||
case "deadline": | ||
String[] taskWithDeadline = inputWords[1].split("/by ", 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.
collections can be named as plural to distinguish from Strings instead of String[]
src/main/java/Duke.java
Outdated
printAddItemText(newDeadlineTask); | ||
break; | ||
case "event": | ||
String[] eventTask = inputWords[1].split("/at ", 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.
same thing here, the naming for eventTask follows that of other Strings, which make it slightly confusing
src/main/java/Task.java
Outdated
return taskType; | ||
} | ||
|
||
public String printTask() { |
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.
code here can be condensed more
src/main/java/Duke.java
Outdated
System.out.println("____________________________________________________________"); | ||
} | ||
|
||
public static void printGreeting() { |
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.
good that helper functions are used to make code neater subsequently
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.
In general, code quality was well-maintained. Good job.
src/main/java/Duke.java
Outdated
System.out.println("____________________________________________________________"); | ||
} | ||
|
||
public static void printGreeting() { |
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 comments to describe what the method does
src/main/java/Duke.java
Outdated
if (previousIcon == "X") { | ||
if (isDone) { | ||
System.out.println("This task has already been marked!"); | ||
} else { | ||
System.out.println("OK, I've marked this task as not done yet:"); | ||
} | ||
} else { | ||
if (!isDone) { | ||
System.out.println("This task has already been unmarked!"); | ||
} else { | ||
System.out.println("Nice! I've marked this task as done:"); | ||
} | ||
} |
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.
The code can be restructured to make the happy path unindented as much as possible.
src/main/java/Duke.java
Outdated
public static void printAddItemText(Task input) { | ||
System.out.println("Got it. I've added this task:"); | ||
System.out.println(input.printTask()); | ||
System.out.println("Now you have " + taskSize + " tasks in the list."); | ||
printHorizontalLine(); | ||
} |
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.
Good job on extracting out the print statements to print methods
src/main/java/Duke.java
Outdated
case "deadline": | ||
String[] taskWithDeadline = inputWords[1].split("/by ", 2); | ||
String taskDescription = taskWithDeadline[0]; | ||
String taskDeadline = taskWithDeadline[1]; | ||
Deadline newDeadlineTask = new Deadline(taskDescription, 'D', taskDeadline); | ||
addItem(newDeadlineTask); | ||
printAddItemText(newDeadlineTask); |
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 varying levels of abstraction to improve readability
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.
Keep coding! 👍
src/main/java/Duke.java
Outdated
printAddItemText(newTodo); | ||
break; | ||
case "deadline": | ||
String[] taskWithDeadline = inputWords[1].split("/by ", 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.
Could 2 be a magic number here?
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.
Here are some comments after your commits 👍
src/main/java/Duke/Duke.java
Outdated
@@ -0,0 +1,213 @@ | |||
package Duke; | |||
|
|||
import Duke.Tasks.*; |
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 list imported classes explicitly, you might have to change IntelliJ settings.
https://se-education.org/guides/conventions/java/basic.html#statements
src/main/java/Duke/Duke.java
Outdated
} | ||
|
||
private static void loadTasksToTasksList() { | ||
try { |
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 you can limit the scope of try-except?
src/main/java/Duke/Duke.java
Outdated
} | ||
} | ||
|
||
public static void main(String[] args) throws EmptyArgumentException, InvalidCommandFormatException, TaskListEmptyException, TaskNumberOutOfBoundsException, IOException, TaskNumberNotNumberException { |
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.
Maybe you can break up this long method?
@@ -0,0 +1,8 @@ | |||
package Duke.Exceptions; | |||
public class DukeException extends Exception { | |||
// protected final String MESSAGE = "☹ OOPS!!! I'm sorry, but I don't know what that means :-("; |
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 deleting this dead code.
if (markStatus.equals("marked")) { | ||
return ERROR_MESSAGE + markStatus + "!"; | ||
} else { | ||
return ERROR_MESSAGE + markStatus + "!"; | ||
} |
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.
Seems the if-else
does not do anything?
if (markStatus.equals("marked")) { | |
return ERROR_MESSAGE + markStatus + "!"; | |
} else { | |
return ERROR_MESSAGE + markStatus + "!"; | |
} | |
return ERROR_MESSAGE + markStatus + "!"; |
} else { | ||
System.out.println("Here are the tasks in your list:"); | ||
for (int i = 0; i < getTasksListSize(); i++) { | ||
System.out.println((i+1) + "." + tasksList.get(i).taskStatusWithDescriptionText()); |
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 between operators.
System.out.println((i+1) + "." + tasksList.get(i).taskStatusWithDescriptionText()); | |
System.out.println((i + 1) + "." + tasksList.get(i).taskStatusWithDescriptionText()); |
Operators should be surrounded by a space character.
https://se-education.org/guides/conventions/java/index.html#layout
Add a find function
No description provided.