-
Notifications
You must be signed in to change notification settings - Fork 454
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
[Bernard Wan De Yuan] iP #461
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # src/main/java/Duke.java # src/main/java/Task.java # text-ui-test/EXPECTED.TXT
# Conflicts: # src/main/java/duke/DukeException.java # src/main/java/duke/TaskList.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.
LGTM! The code looks clean and easy to read, with most of the comments being nit-picky 😂 Think that the logic can be a bit more simplified in Parser
, and that some javadoc is missing. Excellent code, keep up the good work!! 👍
import duke.DukeException; | ||
import duke.Task; | ||
import duke.TaskList; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; |
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.
Should java
related imports come before duke
?
@@ -0,0 +1,42 @@ | |||
package duke.Command; | |||
|
|||
import duke.*; |
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 think perhaps can consider importing individual classes instead of using wildcard import
!
if(type.equals("todo")) { | ||
task = new Task.Todo(description, false); | ||
|
||
} else if(type.equals("deadline")) { | ||
String[] temp = description.split("by ", 2); | ||
task = new Task.Deadline(temp[0], false, temp[1]); | ||
|
||
} else if(type.equals("event")) { | ||
String[] temp = description.split("at ", 2); | ||
task = new Task.Event(temp[0], false, temp[1]); |
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.
Maybe can consider using enum
for this!
src/main/java/duke/Storage.java
Outdated
* Loads task data from storage | ||
* | ||
* @return ArrayList of tasks | ||
* @throws DukeException |
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.
Feel like the condition when the DukeException
is thrown should be specified here :))
src/main/java/duke/Task.java
Outdated
this.status= status; | ||
} | ||
|
||
public static class Todo 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.
Should there be a whitespace before the curly braces?
src/main/java/duke/Parser.java
Outdated
if (input.equals("bye")) { | ||
return new ExitCommand(); | ||
} else if (input.equals("list")) { | ||
return new ListCommand(); | ||
} else if (first_word.equals("done")) { | ||
int index; | ||
try { | ||
index = Integer.parseInt(input.split(" ")[1]) - 1; | ||
} catch (ArrayIndexOutOfBoundsException e) { | ||
throw new DukeException("Sorry, please enter an integer after 'done'. (e.g. done 2)"); | ||
} | ||
return new DoneCommand(index); | ||
} else if (first_word.equals("delete")) { | ||
int index; | ||
try { | ||
index = Integer.parseInt(input.split(" ")[1]) - 1; | ||
} catch (ArrayIndexOutOfBoundsException e) { | ||
throw new DukeException("Sorry, please enter an integer after 'delete'. (e.g. delete 2)"); | ||
} | ||
return new DeleteCommand(index); | ||
} else if (first_word.equals("find")){ | ||
String remaining; | ||
try { | ||
remaining = input.split(" ", 2)[1]; | ||
} catch (ArrayIndexOutOfBoundsException e) { | ||
throw new DukeException("Sorry, please enter a keyword after 'find'."); | ||
} | ||
return new FindCommand(remaining); | ||
} else { | ||
String remaining; | ||
try { | ||
remaining = input.split(" ", 2)[1]; | ||
} catch (ArrayIndexOutOfBoundsException e) { | ||
throw new DukeException("Sorry, tasks must include descriptions."); | ||
} | ||
return new AddCommand(first_word, remaining); | ||
} |
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.
Perhaps we can use enum
here to simplify the logic here! Also, personally I fell that all the try-catch
statement here can be abstracted to other class method e.g. createDone()
etc. to prevent arrowhead style code, and that one single catch
for ArrayIndexOutOfBoundsException
could be used for the entire method. Don't know if I articulate my idea in a very accurate way 😂
src/main/java/duke/Storage.java
Outdated
String line = reader.nextLine(); | ||
String[] data = line.split(" \\| "); | ||
switch (data[0]) { | ||
case "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.
Should case
be on the same indent level as switch
?
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.
LGTM! I think the code is very clean and easy to read and there is very clear abstraction between classes. Well done!
@@ -0,0 +1,30 @@ | |||
package duke.Command; | |||
|
|||
import duke.*; |
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 think you should import package by package, for example import duke.TaskList
rather than using import duke.*
src/main/java/Command.java
Outdated
public abstract class Command { | ||
public abstract void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException; | ||
|
||
public abstract boolean isExit(); |
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 might want to consider setting isExit
to False
in the abstract, then only changing it to True
when it is an ExitCommand. This way you do not have to constantly check what Command it is
Gradle run and shadowJar tasks are not functioning as intended. This should be fixed for ease of use and to create a new JAR release. Let's edit the build.gradle for proper main class declaration. Also,let's fix any checkstyle errors that might inhibit the build process.
There are some left over code from before GUI was implemented. These leftover code that is not used should be removed to improve code quality and readability. Let's check through the code and remove any unused methods or other files.
branch-A-Assertions
Branch a code quality
DUKE
Hi this is my Duke program! It's
Steps to use:
Features:
Sample code
main
: