Skip to content

[Lester Sim Jia Jun] iP - #77

Open
lestersimjj wants to merge 90 commits into
nus-cs2113-AY2122S2:masterfrom
lestersimjj:master
Open

lestersimjj wants to merge 90 commits into
nus-cs2113-AY2122S2:masterfrom
lestersimjj:master

Conversation

@lestersimjj

Copy link
Copy Markdown

No description provided.

Comment thread src/main/java/ChatSession.java Outdated
@@ -0,0 +1,67 @@
import java.util.ArrayList;

public class ChatSession {

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 use of ChatSession class to abstract commands

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

// Execute user commands
switch(userCommand) {

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 catch on the switch-case indentation standard!

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

public void markTaskIndex(int taskID) {
String output = taskList.get(taskID - 1).markTask(); // zero-based indexing

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could move your comments above the line

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

public void unmarkTaskIndex(int taskID) {
String output = taskList.get(taskID - 1).unmarkTask(); // zero-based indexing

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Once again can move your comments above the line

Comment thread src/main/java/ChatSession.java Outdated
@@ -0,0 +1,67 @@
import java.util.ArrayList;

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 on only importing the specific class needed!

Comment thread src/main/java/Duke.java Outdated
userInputArr = userInput.split(" ", 2);
userCommand = userInputArr[0];

if (userCommand.startsWith("bye")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

all methods, conditionals, and loops seem to follow the K&R style brackets, and statements within are all in the next line so that's great

Comment thread src/main/java/ChatSession.java Outdated
Comment on lines +25 to +26
// Create a new Task, append to taskList
// Task newTask = new Task(description);

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 the indentation of these comments could be in line with the code! It seems a little messy here but small issue

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

public class ChatSession {
// Store subclasses of tasks
ArrayList<Task> taskList;

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 naming of array

Comment thread src/main/java/duke/Duke.java Outdated
Comment on lines +73 to +85

switch (taskType) {
case "T":
currChat.addInitialTask(new Todo(isDone, userInputArr[2]));
break;
case "D":
currChat.addInitialTask(new Deadline(isDone, userInputArr[2], userInputArr[3]));
break;
case "E":
currChat.addInitialTask(new Event(isDone, userInputArr[2], userInputArr[3]));
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.

Include the default branch in case statements.

Comment thread src/main/java/duke/Duke.java Outdated
Comment on lines +23 to +29
switch (userCommand) {
case "list":
currChat.printTaskList();
break;
case "mark":
// Additional argument provided by user is the task no. to mark
currChat.markTaskIndex(Integer.parseInt(userInputArr[1]));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider extracting magic strings such as "list", "mark" into constants.

Comment thread src/main/java/duke/ChatSession.java Outdated
Comment on lines +34 to +35
// Create a new Task, append to taskList
taskList.add(task);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid unnecessary comments where the code is self-explanatory.

Comment thread src/main/java/duke/Duke.java Outdated
Comment on lines +40 to +57
break;
case "deadline":
// eg. return book /by Sunday
userArguments = userInputArr[1].split(" /by ", 2);
description = userArguments[0]; //eg. return book
String by = userArguments[1]; // eg. Sunday
currChat.addTask(new Deadline(description, by));
break;
case "event":
// eg. project meeting /at Mon 2-4pm
userArguments = userInputArr[1].split(" /at ", 2);
description = userArguments[0]; // eg. project meeting
String eventTime = userArguments[1]; // eg. Mon 2-4pm
currChat.addTask(new Event(description, eventTime));
break;
case "delete":
currChat.deleteTaskIndex(Integer.parseInt(userInputArr[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.

Should there be input validation for the userArguments?

Comment thread src/main/java/duke/ChatSession.java Outdated
}

// Return the added task
System.out.println("____________________________________________________________");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider extracting repeated strings like this into constants for better reusability.

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