Skip to content

[Low Xi Zhi] iP - #55

Open
lowxizhi wants to merge 29 commits into
nus-cs2113-AY1920S2:masterfrom
lowxizhi:master
Open

[Low Xi Zhi] iP#55
lowxizhi wants to merge 29 commits into
nus-cs2113-AY1920S2:masterfrom
lowxizhi:master

Conversation

@lowxizhi

Copy link
Copy Markdown

No description provided.

@A11riseforme A11riseforme left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a good effort overall! good job

Comment thread src/main/java/Duke.java Outdated
Comment on lines +36 to +47
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Comment thread src/main/java/Duke.java Outdated
}

private static void printListMessage(Task[] taskList, int taskCount) {
System.out.println("\t____________________________________________________________\n"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/main/java/Duke.java Outdated
Comment on lines +25 to +53
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);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 jiajuinphoon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/main/java/Duke.java Outdated
String taskType = words[0];
Task t = new Task(line);
switch (taskType){
case "todo":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job for using switch, will recommend to follow the coding standard because the word "case" must by directly under the switch :)

Comment thread src/main/java/Duke.java Outdated

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")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job to follow the coding standard :)

Comment thread src/main/java/Duke.java Outdated
printGoodbyeMessage();
}

private static void printListMessage(Task[] taskList, int taskCount) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way of printing the task seems neater compared to how I did it. Good Job :)

Comment thread src/main/java/Duke.java Outdated
+ "\t____________________________________________________________\n");
}

private static void printGoodbyeMessage() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job by creating several functions instead of putting everything in the main. :)

@Shannonwje Shannonwje left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/main/java/Duke.java Outdated
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
System.out.println("\t____________________________________________________________\n"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/main/java/Duke.java Outdated
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/main/java/Duke.java Outdated
printDoneMessage(t);
} else {
String taskType = words[0];
Task t = new Task(line);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe consider having a more meaningful variable name to make the code more readable such as newTask. -SWJE

Comment thread src/main/java/Duke.java Outdated
String taskType = words[0];
Task t = new Task(line);
switch (taskType){
case "todo":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/main/java/Duke.java Outdated
printGoodbyeMessage();
}

private static void printListMessage(Task[] taskList, int taskCount) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/main/java/Event.java Outdated
this.at = at;
}

// public void setAt(String at) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can delete away methods that are not needed or used so that the code looks tidier. But awesome code tidiness!!! - SWJE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants