[Low Xi Zhi] iP - #55
Conversation
A11riseforme
left a comment
There was a problem hiding this comment.
a good effort overall! good job
| switch (taskType){ | ||
| case "todo": | ||
| t = new Todo(words[1]); | ||
| break; | ||
| case "deadline": | ||
| String[] deadlineWords = words[1].split(" /by ", 2); // split the deadline task from the by string using /by as the delimiter | ||
| t = new Deadline(deadlineWords[0], deadlineWords[1]); | ||
| break; | ||
| case "event": | ||
| String[] eventWords = words[1].split(" /at ", 2); // split the event task from the by string using /at as the delimiter | ||
| t = new Event(eventWords[0], eventWords[1]); | ||
| break; |
There was a problem hiding this comment.
Indentation is violating the java coding standard. There should be no indentation for case clauses. follow the style below:
switch (condition) {
case ABC:
statements;
// Fallthrough
case DEF:
statements;
break;
case XYZ:
statements;
break;
default:
statements;
break;
}| } | ||
|
|
||
| private static void printListMessage(Task[] taskList, int taskCount) { | ||
| System.out.println("\t____________________________________________________________\n" |
There was a problem hiding this comment.
The string literal can be isolated as a vairable like lineDivider
private static final String LINE_DIVIDER= "\t____________________________________________________________\n";can call this viriable in the later codes.
| String[] words = line.split(" ",2); // split the first word from the rest of the sentence using space as the delimiter | ||
| if (line.equals("list")) { | ||
| printListMessage(taskList, taskCount); | ||
| } else if (words[0].equals("done")) { | ||
| int taskNum = Integer.parseInt(line.substring(5,6)); | ||
| Task t=taskList[taskNum-1]; | ||
| t.markAsDone(); | ||
| printDoneMessage(t); | ||
| } else { | ||
| String taskType = words[0]; | ||
| Task t = new Task(line); | ||
| switch (taskType){ | ||
| case "todo": | ||
| t = new Todo(words[1]); | ||
| break; | ||
| case "deadline": | ||
| String[] deadlineWords = words[1].split(" /by ", 2); // split the deadline task from the by string using /by as the delimiter | ||
| t = new Deadline(deadlineWords[0], deadlineWords[1]); | ||
| break; | ||
| case "event": | ||
| String[] eventWords = words[1].split(" /at ", 2); // split the event task from the by string using /at as the delimiter | ||
| t = new Event(eventWords[0], eventWords[1]); | ||
| break; | ||
| } | ||
| taskList[taskCount] = t; | ||
| taskCount++; | ||
|
|
||
| printAddTaskMessage(taskCount, t); | ||
| } |
There was a problem hiding this comment.
This can be combined into one single switch case structure. extract the first word of the user input.
switch (command) {
case "list":
// list logic
case "done":
// done logic
case "todo":
// todo logic
case "deadline":
.
.
.
}
jiajuinphoon
left a comment
There was a problem hiding this comment.
Overall, you followed the coding standard except the switch case, and the code is generally neat and comfortable to read. Great job. All the best for your ip :)
Also took part in it : @trishaangelica
| String taskType = words[0]; | ||
| Task t = new Task(line); | ||
| switch (taskType){ | ||
| case "todo": |
There was a problem hiding this comment.
Good job for using switch, will recommend to follow the coding standard because the word "case" must by directly under the switch :)
|
|
||
| while (!line.equals("bye")){ | ||
| String[] words = line.split(" ",2); // split the first word from the rest of the sentence using space as the delimiter | ||
| if (line.equals("list")) { |
There was a problem hiding this comment.
good job to follow the coding standard :)
| printGoodbyeMessage(); | ||
| } | ||
|
|
||
| private static void printListMessage(Task[] taskList, int taskCount) { |
There was a problem hiding this comment.
This way of printing the task seems neater compared to how I did it. Good Job :)
| + "\t____________________________________________________________\n"); | ||
| } | ||
|
|
||
| private static void printGoodbyeMessage() { |
There was a problem hiding this comment.
Good job by creating several functions instead of putting everything in the main. :)
Shannonwje
left a comment
There was a problem hiding this comment.
Overall amazing work, especially in explaining the lines of code that may seem confusing to the code-reader. But overall tidiness and javadoc comments can be even better
| + "| |_| | |_| | < __/\n" | ||
| + "|____/ \\__,_|_|\\_\\___|\n"; | ||
| System.out.println("Hello from\n" + logo); | ||
| System.out.println("\t____________________________________________________________\n" |
There was a problem hiding this comment.
Maybe you can consider the printing of the welcome message in another method for the code to be tidier, like what you did for the goodbye message. -SWJE
| String line = in.nextLine(); | ||
|
|
||
| while (!line.equals("bye")){ | ||
| String[] words = line.split(" ",2); // split the first word from the rest of the sentence using space as the delimiter |
There was a problem hiding this comment.
Line 25 of the code seems very long, maybe can consider placing the comment above line 25 to make the code tidier. But good job on explaining the the use of the function in your code. -SWJE
| printDoneMessage(t); | ||
| } else { | ||
| String taskType = words[0]; | ||
| Task t = new Task(line); |
There was a problem hiding this comment.
Maybe consider having a more meaningful variable name to make the code more readable such as newTask. -SWJE
| String taskType = words[0]; | ||
| Task t = new Task(line); | ||
| switch (taskType){ | ||
| case "todo": |
There was a problem hiding this comment.
Can reference the java coding standard for CS2113T for the switch-case statement indentations. There is no indentation for case clauses, for eg.
switch (condition) {
case ABC:
statements;
// Fallthrough
case DEF:
statements;
break;
case XYZ:
statements;
break;
default:
statements;
break;
}
- SWJE
| printGoodbyeMessage(); | ||
| } | ||
|
|
||
| private static void printListMessage(Task[] taskList, int taskCount) { |
There was a problem hiding this comment.
Maybe can consider adding in javadoc comments for methods inside the class. But otherwise, amazing work on making your work tidier by placing them into different methods. -SWJE
| this.at = at; | ||
| } | ||
|
|
||
| // public void setAt(String at) { |
There was a problem hiding this comment.
Maybe can delete away methods that are not needed or used so that the code looks tidier. But awesome code tidiness!!! - SWJE
…line and event exceptions
…b-package. put all classes in the duke package. add exception for commands with only whitespace.
Level-9 add find feature
No description provided.