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.
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.
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.
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.
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.
You can consider making "todo", "deadline", "event" String constants
# Conflicts: # src/main/java/duke/command/Duke.java # src/main/java/duke/task/TaskManager.java
| @@ -0,0 +1,20 @@ | |||
| package duke.task; | |||
|
|
|||
| public class Deadline extends Task { | |||
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.