-
Notifications
You must be signed in to change notification settings - Fork 78
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
[Mark Lin] iP #66
base: master
Are you sure you want to change the base?
[Mark Lin] iP #66
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.
LGTM,
Appropriate use of indentation for the wrapped lines.
Good use of the if-else structure, as stated in the coding standards.
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, naming was done well and the code was easy to read.
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.
Great progress on your iP so far, I have left some comments for potential areas of improvement, especially regarding code quality :)
src/main/java/Duke.java
Outdated
out = "List is empty."; | ||
} | ||
for (int i = 0; i < listAsArray.length; i++) { | ||
out += (i == 0 ? "" : "\n") + (i + 1) + ". " + listAsArray[i].getListText(); |
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.
Try to avoid complicated expressions such as this, consider especially the usage of ternary operators in such contexts, as more complicated comparisons may affect the code readability.
src/main/java/Duke.java
Outdated
switch (line[0]) { | ||
case "T": { | ||
Task task = new Todo(taskName); | ||
task.setIsComplete(isMark); | ||
list.add(task); | ||
break; | ||
} | ||
case "D": { | ||
String by = line[3]; | ||
Task task = new Deadline(taskName, by); | ||
task.setIsComplete(isMark); | ||
list.add(task); | ||
break; | ||
} | ||
case "E": { | ||
String from = line[3].split("-")[0]; | ||
String to = line[3].split("-")[1]; | ||
Task task = new Event(taskName, from, to); | ||
task.setIsComplete(isMark); | ||
list.add(task); | ||
break; |
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 further abstracting out the logic in this portion of the code to avoid deep nesting
src/main/java/Duke.java
Outdated
String from = line[3].split("-")[0]; | ||
String to = line[3].split("-")[1]; |
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.
Try to avoid usage of magic literals, especially in larger projects, in this case, consider assigning your delimiter to a variable, then referencing when needed.
src/main/java/Duke.java
Outdated
throw new DukeException("The description of " + command + " cannot be empty."); | ||
} | ||
return message.substring(command.length(), | ||
message.contains("/") ? message.indexOf("/") : message.length()).trim(); |
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.
Similarly, keep aware of the usage of magic literals.
No description provided.