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

[Bernard Wan De Yuan] iP #461

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

Conversation

bernardwan
Copy link

@bernardwan bernardwan commented Aug 25, 2021

DUKE

“Your mind is for having ideas, not holding them.” – David Allen (source)

Hi this is my Duke program! It's

  • Fun 👍
  • Easy to use
  • text-based

Steps to use:

  1. Download from here
  2. Run
  3. Use!

Features:

  • Managing tasks
  • GUI

Sample code main :

public static void main(String[] args) {
        new Duke().run();
    }

Copy link

@david-eom david-eom left a 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!! 👍

Comment on lines 3 to 8
import duke.DukeException;
import duke.Task;
import duke.TaskList;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;

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.*;

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!

Comment on lines 17 to 26
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]);

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!

* Loads task data from storage
*
* @return ArrayList of tasks
* @throws DukeException

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 :))

this.status= status;
}

public static class Todo extends Task{

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?

Comment on lines 18 to 54
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);
}

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 😂

String line = reader.nextLine();
String[] data = line.split(" \\| ");
switch (data[0]) {
case "todo":

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?

Copy link

@chengseong chengseong left a 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.*;

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

public abstract class Command {
public abstract void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException;

public abstract boolean isExit();

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

3 participants