-
Notifications
You must be signed in to change notification settings - Fork 362
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
Increments for iP #370
base: master
Are you sure you want to change the base?
Increments for iP #370
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.
Up to Week 2 (Level-6), the code is functional and meets all the weekly requirements. There are minor issues regarding the coding standard, and a few suggestions for refactoring in the Duke.java class.
src/main/java/Duke.java
Outdated
} | ||
Task t = new Task.Todo(textInput.substring(5)); | ||
taskList.add(t); | ||
String output = String.format("Got it. I've added this task:\n%s\nNow you have %d tasks in the list", t.toString(), taskList.size()); |
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.
This output line seems very long, is it possible to split them into 2 lines?
A similar issue appears in line 32, 78, 88.
src/main/java/Duke.java
Outdated
if (textInput.equalsIgnoreCase("list")) { | ||
System.out.println("Here are the tasks in your list:"); | ||
for (int i = 0; i < taskList.size(); i++) { | ||
System.out.println(i + 1 + ". " + taskList.get(i).toString()); |
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.
This manual string formatting works, however, have you considered using Java's builtin String.format method?
src/main/java/DukeException.java
Outdated
@@ -0,0 +1,5 @@ | |||
public class DukeException extends Exception{ |
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.
For this class and your Task class, can you indent it with 4 spaces instead of 2?
src/main/java/Duke.java
Outdated
taskList.remove(i - 1); | ||
String output = String.format("Got it. I've removed this task:\n%s\nNow you have %d tasks in the list", t.toString(), taskList.size()); | ||
System.out.println(output); | ||
continue; |
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 find the use of multiple continue
instructions in the code strange. The while loop already has a looping behaviour once it reaches the end of the loop, so using continue
to return to the start of the loop should not be a default behaviour. What is your rationale for designing it this way?
Rather, I would suggest the following structure:
boolean isRunning = true;
while (isRunning) {
if (textInput.equalsIgnoreCase("bye")) {
isRunning = false;
} else if (stmt) {
code;
} else {
code;
}
}
Alternatively, you may consider parsing the command first, then using a switch-case statement to handle various cases.
src/main/java/Duke.java
Outdated
@@ -1,10 +1,96 @@ | |||
import java.util.ArrayList; |
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.
Would prefer if the code was in a package, eg: package duke.
These are mainly done when the user is adding tasks to the TaskList through "deadline" and "event". Adding these assertions improves Duke's user experience and handles invalid user inputs better.
…es, and CSS styling. There are several ways code quality was improved. For example, better OOP was implemented by abstracting away code from initialize() to setDuke() in MainWindow.java. Improving the code quality helps to improve readability and adding CSS styling helps to improve the user experience.
This can be done with the following structure: "postpone <task name> /to <new deadline>". Adding this postpone feature can improve the functionalities available to the user.
Added user guide for better readibility.
Add assertions to ensure that the user inputs are always valid.
Branch a code quality
Duke
Duke frees your mind of having to remember things you need to do. It's,
All you need to do is,
And it is FREE! Wow!
Features:
If you Java programmer, you can use it to practice Java too. Here's the main method: