-
Notifications
You must be signed in to change notification settings - Fork 193
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
[Rachel Keh] iP #190
base: master
Are you sure you want to change the base?
[Rachel Keh] iP #190
Conversation
adding in Task class only now even though it was introduced in the level 1 increment because I forgot to let Git track it
…tions and invoke from main. Change taskDetails to description in Task class to flow with the rest of the code and avoid unnecessary confusion. Change a few magic numbers into constants in TaskManager class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 👍
src/main/java/Duke.java
Outdated
Scanner in = new Scanner(System.in); | ||
line = in.nextLine(); | ||
|
||
TaskManager t1 = new TaskManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you consider a better variable name?
src/main/java/TaskManager.java
Outdated
String[] details = keywords[1].split(" /"); | ||
tasks[Task.getNumberOfTasks()] = new Event(details[0], details[1].substring(DESCRIPTION_AFTER_BY_OR_AT)); | ||
} | ||
System.out.println(" _____________________________________________________________"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you consider creating a println function to use instead?
src/main/java/TaskManager.java
Outdated
@@ -0,0 +1,41 @@ | |||
public class TaskManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that the TaskManager is seperate from Duke. Makes the code more readable.
src/main/java/TaskManager.java
Outdated
|
||
public void addTask(String line) { | ||
String[] keywords = line.split(" ", 2); | ||
if (keywords[INDEX_OF_KEYWORD_OF_TASK].equalsIgnoreCase("todo")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can consider making "todo", "deadline", "event" String constants
# Conflicts: # src/main/java/duke/command/Duke.java # src/main/java/duke/task/TaskManager.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some suggestions to improve your code quality. Coding style looks good to me :)
@@ -0,0 +1,20 @@ | |||
package duke.task; | |||
|
|||
public class Deadline extends Task { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! You made use of OOP to make Deadline a subclass of Task :)
if (words[0].equals("T")) { | ||
tasks.add(new Todo(words[2])); | ||
if (words[1].equals("true")) { | ||
tasks.get(Task.getNumberOfTasks() - 1).setDone(); //else leave isDone as false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By splitting this line into two lines like this:
int lastTaskIndex = Task.getNumberOfTasks() - 1;
tasks.get(lastTaskIndex).setDone()
helps to improve code readability
} else if (words[0].equals("D")) { | ||
tasks.add(new Deadline(words[2], words[3])); | ||
if (words[1].equals("true")) { | ||
tasks.get(Task.getNumberOfTasks() - 1).setDone(); //else leave isDone as false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is kinda simple and self-explanatory. Hence, I feel the comment is rather redundant. You may consider removing it :)
if (words[1].equals("true")) { | ||
tasks.get(Task.getNumberOfTasks() - 1).setDone(); //else leave isDone as false | ||
} | ||
} else { //the only type of Task left is Event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to write the comment in a new line to improve code readability :)
printIncorrectInput(isEmptyDescription, keywords[INDEX_OF_KEYWORD_OF_TASK]); | ||
} | ||
} | ||
if (hasNoException) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using a boolean to see if an exception has occurred, you may consider throwing the exception back to the caller method and let the calling method handle the exception. In that way, you can confidently printAddedTasked() and updateFile(). Because if an exception had occurred, an exception will be thrown from the method and this part of the code will not be reached. Just a suggestion :)
|
||
public void markAsDone(String index) { | ||
try { | ||
int indexInteger = Integer.parseInt(index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are calling this variable index, you can do the -1 in this line itself
int indexInteger = Integer.parseInt(index) - 1;
|
||
public void deleteTask(String index) { | ||
try { | ||
int indexInteger = Integer.parseInt(index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same suggestion. If you do -1 in this line, you don't have to do it everywhere else in this method.
int indexInteger = Integer.parseInt(index) - 1;
Add Level 9 - Find increment.
Add A-JavaDoc - JavaDoc increment.
Update README.md
No description provided.