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

[Hong Jiancheng] iP #4

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

Conversation

HongJiancheng
Copy link

No description provided.

Comment on lines 32 to 55
case "todo":
store.addToDoToTemp(others);
ui.printLine();
ui.indentPrint("Got it. I've added this task: ");
ui.indentPrint(" "+store.getTask(store.getSize()-1).toString());
ui.indentPrint( "Now you have "+store.getSize()+" tasks in the list.");
ui.printLine();
break;
case "deadline":
store.addDeadlineToTemp(others);
ui.printLine();
ui.indentPrint("Got it. I've added this task: ");
ui.indentPrint(" "+store.getTask(store.getSize()-1).toString());
ui.indentPrint( "Now you have "+store.getSize()+" tasks in the list.");
ui.printLine();
break;
case "event":
store.addEventToTemp(others);
ui.printLine();
ui.indentPrint("Got it. I've added this task: ");
ui.indentPrint(" "+store.getTask(store.getSize()-1).toString());
ui.indentPrint( "Now you have "+store.getSize()+" tasks in the list.");
ui.printLine();
break;
Copy link
Author

Choose a reason for hiding this comment

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

I felt these codes are highly repeated with each other, but don't know how to make it nicer.

Any suggestions?

Copy link

Choose a reason for hiding this comment

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

I would consolidate the steps (print the message, print the task) and write a new function to handle it

Copy link
Author

Choose a reason for hiding this comment

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

Sounds great! I will try to work in this direction.

Copy link

@dgc5213 dgc5213 left a comment

Choose a reason for hiding this comment

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

Overall, it is very good. The program follows coding standard and it has high code quality.

command = input;
others = "";
}
switch (command) {
Copy link

Choose a reason for hiding this comment

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

I like this part. Using "switch" to compare the input can maximise readability and easier for user to read

ui.indentPrint( "Now you have "+store.getSize()+" tasks in the list.");
break;
case "deadline":
if(others.isEmpty()){
Copy link

Choose a reason for hiding this comment

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

It is good to have empty value checking. To further improve, I would like to suggest to create a new method/function to check empty value regardless it is "deadline","event",“todo","done". Then, it can help you avoid the long method (getCommand ).

Copy link
Author

Choose a reason for hiding this comment

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

Make sense, will try to create a function to handle it.

String by = toAdd.split(" /by ")[1];
tempStorage.add(new Deadline(description,by));
}
public void addEventToTemp(String toAdd) throws DukeException{
Copy link

Choose a reason for hiding this comment

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

It is great, you have multiple Exception cases. the error message is meaningful to the user.

HongJiancheng and others added 30 commits January 26, 2021 20:01
Final Enhancement with help command and duplicate command improvement
Update Developer Guide Images
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.

2 participants