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

[Nicholas Arlin Halim] iP #276

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

Conversation

daytona65
Copy link

@daytona65 daytona65 commented Jan 26, 2023

DukeMeister3000

"Tasks not complete, until DukeMeister3000 I used" - Mister Yoda

DukeMeister3000 tracks your tasks and gives you that edge to complete them on time. It is

  • extremely intuitive
  • fast
  • quite very ABSOLUTELY simple to use

Simply

  1. Download it here
  2. Run it as a jar file
  3. Start typing your tasks
  4. And there you have it!

Let DukeMeister3000 manage your tasks for you! 💯

Some features:

  • Deadline setting
  • Display your current tasks
  • Stores your tasks when you stop the program and accesses them again on the next startup

If you are a Java programmer, you can review the code easily with its well designed code and JavaDocs. Here's the newEvent method:

    /**
     * Creates a new Event task and prints a message for the user
     * confirming the addition of the task to the Task List.
     *
     * @param input The user input.
     * @param taskSize The current Task List size.
     * @return The created task.
     */
    public Task newEvent(String input, int taskSize) throws DukeException {
        int fromIndex = input.indexOf(" /from ");
        int toIndex = input.indexOf(" /to ");
        Task task = new Event(input.substring(6, fromIndex), input.substring(fromIndex + 7, toIndex),
                input.substring(toIndex + 5));
        Ui.addMessage(task, taskSize);
        return task;
    }

Copy link

@Dangabit Dangabit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding standard wise it mostly look fine!
Some possible improvements are commented.

public class Duke {
private static Scanner sc;
private static List<Task> list;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a better variable name than list here to indicate what the list holds?

Suggested change
private static List<Task> list;
private static List<Task> tasks;

@@ -0,0 +1,13 @@
public class Deadline extends Task {
protected String by;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a more descriptive variable name would be more helpful.

Suggested change
protected String by;
protected String dueDate;

} else if (isMark(input, list.size())) {
int taskindex = Integer.parseInt(input.substring(5)) - 1;
list.get(taskindex).markAsDone();
System.out.println("Solid! I'm marking this task as done:\n" + list.get(taskindex).toString());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line may have been too long, perhaps separate into multiple lines to be more aligned with the coding standard. There are also more similar issues further below.

@@ -0,0 +1,13 @@
public class Deadline extends Task {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe organising your Deadline, Todo, Event and task into a single package will help with the structure of your files. Also helps as you implement more classes.

}
}

public static boolean isMark(String input, int listSize) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All your methods are aptly named with the right names and format. Nice!

Copy link

@KSunil2001 KSunil2001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, almost. Just a few nits to fix.
Overall, the code is well done 😄

Comment on lines 24 to 64
if ("bye".equals(input)) {
break;
} else if ("list".equals(input)) {
System.out.println("Here are the tasks in your list:");
for (int i = 0; i < list.size(); i++) {
int j = i + 1;
System.out.println(j + "." + list.get(i).toString());
}
} else if (isMark(input, list.size())) {
int taskindex = Integer.parseInt(input.substring(5)) - 1;
list.get(taskindex).markAsDone();
System.out.println("Solid! I'm marking this task as done:\n" + list.get(taskindex).toString());
} else if (isUnMark(input, list.size())) {
int taskindex = Integer.parseInt(input.substring(7)) - 1;
list.get(taskindex).markAsNotDone();
System.out.println("Aight, marking this as not done:\n" + list.get(taskindex).toString());
} else if (isDelete(input, list.size())) {
int taskindex = Integer.parseInt(input.substring(7)) - 1;
String removed = list.get(taskindex).toString();
list.remove(taskindex);
System.out.println("Swee! One less task to go! Removing...\n" + removed);
} else { //Task Creation
Task task = null;
if (isToDo(input)) {
task = new ToDo(input);
list.add(task);
} else if (isDeadline(input)) {
int index = input.indexOf(" /by ");
task = new Deadline(input.substring(0, index), input.substring(index + 5));
list.add(task);
} else if (isEvent(input)) {
int fromdex = input.indexOf(" /from ");
int todex = input.indexOf(" /to ");
task = new Event(input.substring(0, fromdex), input.substring(fromdex + 7, todex), input.substring(todex + 5));
list.add(task);
} else {
throw new DukeException("What are you saying?\n" + "Please input a task with either todo, deadline or event prefixed!");
}
System.out.println("Roger. This task has been added:\n" + " " + task.toString());
System.out.println("Now you have " + list.size() + " tasks in your list.");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could use switch case statements instead of if-else statements for better readability? 🤔


public static boolean isDeadline(String input) throws DukeException {
if (input.length() >= 8 && input.startsWith("deadline")) {
if (input.equals("deadline") || input.substring(8).isBlank() || input.equals("deadline /by") || input.equals("deadline /by ")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend breaking this statement into 2 lines to make the code look more neat.

Comment on lines 116 to 120
int fromdex = input.indexOf(" /from ");
int todex = input.indexOf(" /to ");
if (fromdex + 7 > todex) {
throw new DukeException("What are you saying?");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be additional indentation to these 5 lines of code.


@Override
public String toString() {
return "[" + getStatusIcon() + "] " + getDescription();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is getDescription() necessary here? 🤔

Suggested change
return "[" + getStatusIcon() + "] " + getDescription();
return "[" + getStatusIcon() + "] " + description;

Comment on lines 76 to 99
public static boolean isUnMark(String input, int listSize) {
if (input.length() >= 8 && input.startsWith("unmark ") && isNumeric(input.substring(7))) {
int taskindex = Integer.parseInt(input.substring(7)) - 1;
return !(taskindex < 0 || taskindex > listSize - 1);
}
return false;
}

public static boolean isDelete(String input, int listSize) {
if (input.length() >= 8 && input.startsWith("delete ") && isNumeric(input.substring(7))) {
int taskindex = Integer.parseInt(input.substring(7)) - 1;
return !(taskindex < 0 || taskindex > listSize - 1);
}
return false;
}

public static boolean isToDo(String input) throws DukeException {
if (input.length() >= 4 && input.startsWith("todo")) {
if (input.equals("todo") || input.substring(4).isBlank()) {
throw new DukeException("TODO needs a description!");
} else return input.startsWith("todo ");
}
return false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you have defined your functions clearly and also applied the KISS rule. Well done 😄

nichalim and others added 19 commits February 1, 2023 21:57
Command classes are all user commands parsed from user inputs, and
are executable. Extracting a Command class allows for better OOP
and modularity of the code.

Execution of commands is extracted from Parser class into Command
classes. Each command is a subclass of the abstract Command class
and each command implements execute() differently.

This allows for modularity and better OOP so more commands can easily
be added in the future. The code is also easier to understand and
functionality and execution of the commands are abstracted away
into the corresponding Command classes instead of just the Parser class.
daytona65 and others added 30 commits February 17, 2023 13:31
Add assertions in Command, Task and Duke
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.

None yet

3 participants