Skip to content
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

[Vincent Lau Han Leong] iP #183

Open
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

vincentlauhl
Copy link

No description provided.

@vincentlauhl vincentlauhl reopened this Sep 1, 2021
@vincentlauhl vincentlauhl changed the title Vincent Lau Han Leong iP [Vincent Lau Han Leong] iP Sep 1, 2021
Copy link

@Jiale-Sun Jiale-Sun left a comment

Choose a reason for hiding this comment

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

The codes are of precision with accurate format of coding as well as appropriate naming.

@@ -0,0 +1,15 @@
public class Deadline extends Task{

Choose a reason for hiding this comment

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

A minor code improvement: add a space before the "{"

case TODO:
parsedOutput = new String[]{input};
break;

Choose a reason for hiding this comment

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

Perhaps you could delete the empty line between each case in the switch function. It was not shown in the lectures. Also, I think it is better to keep the consistency of format (since you did not add any empty line before or after this).

Comment on lines 155 to 158
if(input.length() != 6) {
printIncorrectInputMessage();
return;
}
Copy link

@rizemon rizemon Sep 2, 2021

Choose a reason for hiding this comment

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

Good use of this guard clause and I am able to see the "good path" of the method.

Comment on lines 111 to 123
switch(type) {
case TODO:
parsedOutput = new String[]{input};
break;

case DEADLINE:
parsedOutput = input.split(DEADLINE_DESCRIPTION_AND_DATE_SPLITTER);
break;

case EVENT:
parsedOutput = input.split(EVENT_DESCRIPTION_AND_DATE_TIME_SPLITTER);
break;
}
Copy link

Choose a reason for hiding this comment

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

Perhaps you could add a default branch? The default branch can be used to raise a suitable error as I think the execution should not reach the default branch. I also noticed this same issue in your other switch statements.

}

private static void processInput(String input) {
switch(input.split(" ")[0].toLowerCase()) {
Copy link

Choose a reason for hiding this comment

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

Perhaps you could create a variable with a meaningful name to simplify the expression in the switch statement?

Comment on lines 62 to 79
switch(input.split(" ")[0].toLowerCase()) {
case "list" :
executeListCase();
break;
case "done" :
executeDoneCase(input);
break;
case "todo" :
executeTaskCase(input, TODO_STARTING_INDEX,TaskType.TODO);
break;
case "deadline" :
executeTaskCase(input, DEADLINE_STARTING_INDEX,TaskType.DEADLINE);
break;
case "event" :
executeTaskCase(input, EVENT_STARTING_INDEX,TaskType.EVENT);
break;
default :
printIncorrectInputMessage();
Copy link

Choose a reason for hiding this comment

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

I like how the Single Level of Abstraction Principle is being applied here and I find it very easy to read and understand what you are trying to do.

case "todo":
try {
executeTaskCase(input, TODO_STARTING_INDEX, TaskType.TODO);

Choose a reason for hiding this comment

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

Suggest to keep consistent the new line convention throughout the code.

return parsedOutput;
}

private static void addTask(String input,TaskType type) throws StringIndexOutOfBoundsException, DukeException {

Choose a reason for hiding this comment

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

Suggest to relocate the function definition from "throw" onwards to a new line with appropriate line indent.

tasks[Task.getTotalTasks()] = new ToDo(parsedOutput[0]);
break;
case EVENT:
if(parsedOutput.length < 2) {

Choose a reason for hiding this comment

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

Suggest to replace magic number with a well-named constant.

printWordsWithIndentation(LIST_IS_EMPTY);
}
for (int i = 0; i < Task.getTotalTasks(); i++) {
printWordsWithIndentation(i + 1 + "." + tasks[i].getStatusIconAndDescription());

Choose a reason for hiding this comment

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

Suggest to relocate expression in function argument to a separate line with appropriate comments.

if(input.length() < 6) {
throw new DukeException();
}
int index = Integer.parseInt(input.split(" ")[1]) - 1;

Choose a reason for hiding this comment

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

Suggest to replace magic number with a well named constant.

vincentlauhl and others added 18 commits September 26, 2021 17:15
Add date and time for event and deadline and some constants
# Conflicts:
#	src/main/java/commands/PrintOptions.java
#	src/main/java/parser/Parser.java
#	src/main/java/tasklist/TaskList.java
#	src/main/java/ui/Ui.java
# Conflicts:
#	src/main/java/commands/AddCommand.java
#	src/main/java/commands/DeleteCommand.java
#	src/main/java/commands/DoneCommand.java
#	src/main/java/commands/IncorrectCommand.java
#	src/main/java/commands/ListCommand.java
#	src/main/java/duke/Duke.java
#	src/main/java/parser/Parser.java
#	src/main/java/task/Deadline.java
#	src/main/java/task/Event.java
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