Skip to content

[Agamjyot] IP - #508

Open
garfield-oo7 wants to merge 81 commits into
nus-cs2103-AY2223S1:masterfrom
garfield-oo7:master
Open

[Agamjyot] IP#508
garfield-oo7 wants to merge 81 commits into
nus-cs2103-AY2223S1:masterfrom
garfield-oo7:master

Conversation

@garfield-oo7

Copy link
Copy Markdown

No description provided.

@nehcuy nehcuy left a comment

Copy link
Copy Markdown

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. 😄

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

class ChatBot {

private String name;

Copy link
Copy Markdown

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 thread src/main/java/Duke.java Outdated
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
Copy Markdown

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
Copy Markdown
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.

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

public void markDone(int index) {

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

Copy link
Copy Markdown

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.

Comment thread src/main/java/Task.java Outdated
return (isDone ? "X" : " "); // mark done task with X
}

public void done(boolean done) {

Copy link
Copy Markdown

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
Copy Markdown
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

Comment thread src/main/java/Storage.java Outdated
while(sc.hasNextLine()) {

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

Copy link
Copy Markdown

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 thread src/main/java/Storage.java Outdated
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
Copy Markdown

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 thread src/main/java/Task.java
Comment on lines +11 to +15
public Task(String description, boolean isDone) {

this.description = description;
this.isDone = isDone;
}

Copy link
Copy Markdown

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
Copy Markdown
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.

@nehcuy nehcuy Sep 3, 2022

Copy link
Copy Markdown

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