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

[Agamjyot] IP #508

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

Conversation

garfield-oo7
Copy link

No description provided.

Copy link

@nehcuy nehcuy left a comment

Choose a reason for hiding this comment

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

I've only commented out violations of code quality guidelines, and I believe there are some coding standards to correct as well.
Also, not very sure if all the extra lines after the method and class declarations are necessary. It might save a lot more LoC if the empty lines were omitted for shorter code that is easier to read. 😄


class ChatBot {

private String name;
Copy link

Choose a reason for hiding this comment

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

Nothing major, but I feel like naming it botName would be clearer to understand, since later on there will be many possible instances of "names of tasks" and such.

Comment on lines 56 to 60
chatBot.addTask(new Deadline(command[0], command[1]));
break;
case "event":
command = sc.nextLine().split(" /at ");
chatBot.addTask(new Events(command[0], command[1]));
Copy link

Choose a reason for hiding this comment

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

Perhaps it would be better to abstract out command[0] and command[1] by doing:

  • keyword = command[0] or firstWord = command[0]
  • restOfCommand = command[1]

before you pass it into your Class Constructors for greater clarity. 😄

Copy link
Author

Choose a reason for hiding this comment

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

yes, thank you for pointing that out, will make the changes in future commits.


public void markDone(int index) {

this.tasks.get(index).done(true);
Copy link

Choose a reason for hiding this comment

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

Since you have a relatively long chain of code to run, it might be better to omit the this at the start of the code and just use tasks.get(index).done(true) instead. This also applies to all the instances of this.tasks you used in this ChatBot Class.

return (isDone ? "X" : " "); // mark done task with X
}

public void done(boolean done) {
Copy link

Choose a reason for hiding this comment

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

Isn't this method a little confusing, since it has the same name as the variable being passed inside? It might be better if it was called markTaskDone() or markDone() in short. The variable passed could be changed to boolean taskCompletionStatus for greater clarity as well.

Copy link
Author

Choose a reason for hiding this comment

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

yes, naming the method as markTaskAsDone or markDone() will be better than just naming it done. I will make the necessary changes

while(sc.hasNextLine()) {

String task = sc.nextLine();
char type = task.charAt(0);
Copy link

Choose a reason for hiding this comment

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

type could be more clearly specified to be taskType.

Comment on lines 52 to 58
taskList.add(new ToDo(description[0], isDone));
break;
case 'D':
taskList.add(new Deadline(description[0], isDone, description[1]));
break;
case 'E':
taskList.add(new Events(description[0], isDone, description[1]));
Copy link

Choose a reason for hiding this comment

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

Similarly, you could abstract out

  1. description[0] to be taskName = description[0] and
  2. description[1] to be restOfDescription = description[1]

before passing them into the respective Constructors.

Comment on lines 11 to 15
public Task(String description, boolean isDone) {

this.description = description;
this.isDone = isDone;
}
Copy link

Choose a reason for hiding this comment

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

Is this Constructor overload really necessary? From my understanding, all Tasks created should, by default, not be completed yet.

Copy link
Author

Choose a reason for hiding this comment

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

Initially all tasks are created by default has not having been completed, but when you pass a task to mark() method then we also need to provide the boolean of the task has been done.

Copy link

@nehcuy nehcuy Sep 3, 2022

Choose a reason for hiding this comment

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

Ah okay, I realised you are creating a new Task with this constructor in the Storage Class when you are reading in the duke.txt file to create the new Task instance based on whether the Task was marked done or not. I guess this could work then.

What I did was to create a default undone Task, then just subsequently use an if else statement to check for '1' or '0' and simply call the respective markDone() and markUndone() methods. This can remove the need for a Constructor overload 🙂

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