[yangyi-zhu] iP - #174
Conversation
Renamed chatbot
LEESY02
left a comment
There was a problem hiding this comment.
I think majority of the code looks good! I gave some minor edit suggestions, to give them some consideration :D
| private static final Task[] list = new Task[100]; | ||
|
|
||
| /** | ||
| public static void echo(String msg) { |
There was a problem hiding this comment.
The commented code seems to be a snippet of code from a previous Level, perhaps it could be removed as it does not help the readers understand what is going on with your code.
| public static void checkInput(String msg) { | ||
| if (msg.equals("list")) { | ||
| System.out.println(NL + DIVIDER + NL + "Tasks:"); | ||
| for (int i = 0; i < count; i++) { |
There was a problem hiding this comment.
Maybe you could refactor each of the if cases into a method
Instead of using multiple lines of else if, perhaps having a single case() switch will be easier to read as well
There was a problem hiding this comment.
e.g.: the lines of code for the list function could be
if (msg.equals("list")) {
printList();
}
To simplify the method in general and making it easier to read
|
|
||
| public static void main(String[] args) { | ||
| Scanner msg = new Scanner(System.in); | ||
| System.out.println( |
There was a problem hiding this comment.
I think it would be easier to read if each of these print messages are encapsulated in a method, to make the main method shorter and more concise
There was a problem hiding this comment.
for e.g.:
public static void main(String[] args) {
Scanner msg = new Scanner(System.in);
printIntroMessage();
.......
printOutroMessage();
}
private static void printIntroMessage() {
sout("This is an intro message :D");
}
private static void printOutroMessage() {
sout("This is an outro message :D");
}
| private String desc; | ||
| private boolean isDone; | ||
|
|
||
| // Type 0: To-do (default) |
There was a problem hiding this comment.
Perhaps instead of using int type to identify the different sub tasks, could have Task as a parent class and the other subtasks as a children class
i.e.:
public class Task {
}
public class ToDo extends Task {
}
Using super classes' toString() in the child's classes' toString is an idea to automate the printing of each task
Task's toString: "[ ] Task A"
Child's toString: "[T]" + super.toString()
Of course this is a very simplified example, it is up to you on how you implement it
| @@ -0,0 +1,94 @@ | |||
| import java.util.Scanner; | |||
There was a problem hiding this comment.
Overall it was a good read with all the functionalities, there is only a few things to touch up :D
| @@ -1,4 +1,4 @@ | |||
| public class Duke { | |||
| public class Baguette { | |||
| msg + "\n" + | ||
| "-------------------------- \n"); | ||
| Scanner newMsg = new Scanner(System.in); | ||
| echo(newMsg.nextLine()); |
There was a problem hiding this comment.
This commented code looks like a code of the previous level so remove it :) for better code quality
| int type = 0; // defaults to to-do if no prefix | ||
| int index = 0; | ||
|
|
||
| if (msg.startsWith("todo ")) { |
There was a problem hiding this comment.
Good job on not using the arrowhead style code style
| // Type 2: Event | ||
| private int type; | ||
|
|
||
| public Task(String description, int type) { |
There was a problem hiding this comment.
Good job on structuring the code logically
| System.out.println((i + 1) + ". " + list[i]); | ||
| } | ||
| System.out.println(DIVIDER + NL); | ||
| } else if (msg.startsWith("mark ")) { |
There was a problem hiding this comment.
Good job on not using the arrowhead style code
|
|
||
| @Override | ||
| public String toString() { | ||
| String typeBox = new String(""); |
Removed redundant commented method from an earlier increment
Added block preventing users from entering blank descriptions for to-dos
Fixed displaying a false message about a null task being added when a list is requested
| private static int count = 0; | ||
| private static final Task[] list = new Task[100]; | ||
|
|
||
| public static void checkInput(String msg) { |
There was a problem hiding this comment.
Avoid lengthy methods. Keep the length of each method to about 30 lines of code.
|
|
||
| @Override | ||
| public String toString() { | ||
| return getType() + (isDone ? "[✓] " : "[ ] ") + desc; |
| System.out.println( | ||
| NL + DIVIDER + NL + | ||
| "The supported types and corresponding formats are as follows:" + NL + | ||
| "To-Dos: todo [description]" + NL + | ||
| "Deadlines: deadline [description] ddl: [DD-MM-YY HH:MM]" + NL + | ||
| "Events: event [description] from: [DD-MM-YY HH:MM] to: [DD-MM-YY HH:MM]" + NL + | ||
| NL + "Examples:" + NL + | ||
| "todo Do the laundry" + NL + | ||
| "deadline CS2113 Increment L5 ddl: 14-02-25 16:00" + NL + | ||
| "event Josh's birthday party from: 03-03-25 15:00 to: 04-03-25 00:00" + | ||
| NL + DIVIDER + NL |
There was a problem hiding this comment.
Since the print statements are common for many commands - you can consider creating a function instead of repeating the same code lines for each command
Replaced magic string messages with constants stored in a distinct utility class Renamed Main file
…ith constants Renamed Messages to Constants
Branch level 6
Added logo display to the welcome message
Added ability to save list and load from file locally
Fixed problems with prefix length resulting in erroneous load ins
Updated long strings to match coding standards
Added feature to search for tasks containing a keyword
Updated Deadline and Event classes to use LocalDateTime instead of pl…
Fixed an error with events displaying the dates twice
fix: Fixed marking and unmarking invalid indices crashing the program fix: Completed and incomplete tasks can no longer be marked and unmarked respectively refactor: Reduced nesting levels
Branch ug
No description provided.