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

[Janice Toh] iP #66

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

Conversation

Janicetyy
Copy link

No description provided.

Copy link

@chaosInTheWild chaosInTheWild left a comment

Choose a reason for hiding this comment

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

Overall, I could not find any coding standard violations, so great job on that! 💯
The code was also easy to understand and it would be even better if you could apply SLAP and shorten some of the methods in some of the parts that I have highlighted. Keep up the good work and all the best for your iP 👍
[Also took part in this review: @JLoh579 ]

protected String by;

public Deadline (String description, String by){
super(description, "D");

Choose a reason for hiding this comment

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

I was thinking perhaps you can consider defining a variable that corresponds to "D"? It might be better to not use a magic string like "D" that does not explain anything about its meaning


public class Jan {

public static final int MAXIMUM_TASK = 100;

Choose a reason for hiding this comment

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

I really like how you defined a constant MAXIMUM_TASK instead of using a magic number! 👍

Comment on lines 7 to 57
public static void executeInstruction(String command, Task[] Tasks, String commandDescription){
System.out.println("____________________________________________________________");
switch(command) {
case "greet":
System.out.println("Hello! I'm Jan\n" + " What can I do for you?");
break;
case "bye":
System.out.println("Bye. Hope to see you again soon!");
break;
case "list":
System.out.println("Here are the tasks in your list:");
for (int i = 0; i < Task.getTotalTask(); i++) {
System.out.println(Tasks[i].getTaskNum() + ". " + Tasks[i]);
}
break;
case "done":
int taskNum = Integer.parseInt(commandDescription) - 1;
if (taskNum < Task.getTotalTask()) {
System.out.println("Nice! I've marked this task as done: ");
Tasks[taskNum].setDone(true);
System.out.println(Tasks[taskNum]);
}else{
System.out.println("Jan cannot find this task");
}
break;
case "todo":
Todo todo = new Todo(commandDescription,"T");
System.out.println("Got it. I've added this task:\n " + todo);
printCurrentTaskCount();
Tasks[Task.getTotalTask() - 1] = todo;
break;
case "deadline":
String[] deadlineDetails = commandDescription.split("/by");
Deadline deadline = new Deadline(deadlineDetails[0],deadlineDetails[1]);
System.out.println("Got it. I've added this task:\n " + deadline);
printCurrentTaskCount();
Tasks[Task.getTotalTask() - 1] = deadline;
break;
case "event":
String[] eventDetails = commandDescription.split("/at");
Event event = new Event(eventDetails[0],eventDetails[1]);
System.out.println("Got it. I've added this task:\n " + event);
printCurrentTaskCount();
Tasks[Task.getTotalTask() - 1] = event;
break;
default:
System.out.println("Duke cannot understand your command.\n");
break;
}
System.out.println("____________________________________________________________");
}

Choose a reason for hiding this comment

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

Perhaps you can consider shortening this method since it is about 50 lines of code? Maybe you can consider applying refactoring, especially extracting the methods for each "case"?

Comment on lines 32 to 51
case "todo":
Todo todo = new Todo(commandDescription,"T");
System.out.println("Got it. I've added this task:\n " + todo);
printCurrentTaskCount();
Tasks[Task.getTotalTask() - 1] = todo;
break;
case "deadline":
String[] deadlineDetails = commandDescription.split("/by");
Deadline deadline = new Deadline(deadlineDetails[0],deadlineDetails[1]);
System.out.println("Got it. I've added this task:\n " + deadline);
printCurrentTaskCount();
Tasks[Task.getTotalTask() - 1] = deadline;
break;
case "event":
String[] eventDetails = commandDescription.split("/at");
Event event = new Event(eventDetails[0],eventDetails[1]);
System.out.println("Got it. I've added this task:\n " + event);
printCurrentTaskCount();
Tasks[Task.getTotalTask() - 1] = event;
break;

Choose a reason for hiding this comment

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

Perhaps you can consider applying SLAP to the blocks of code under "todo", "deadline" and "event". For example, line 35 and lines 33-34 are not in the same level of abstraction, one is a function call whereas the other is performing a computation directly.

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