Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[randallnhr] iP #389

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

Conversation

randallnhr
Copy link

@randallnhr randallnhr commented Feb 3, 2023

DukeBot

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

DukePro frees your mind of having to remember things you need to do. It's,

  • text-based
  • easy to learn
  • FAST SUPER FAST to use

Where do I begin?

All you need to do is,

  1. download the JAR file from (here).
  2. double-click it.
  3. add your tasks.
  4. let it manage your tasks for you 😉

And it is FREE!

Features

  • Managing tasks
  • Managing deadlines (coming soon)
  • Reminders (coming soon)

protected String startDate;
protected String endDate;

public Task(String name, String date1, String date2) {

Choose a reason for hiding this comment

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

would it be better to abstract out startDate and endDate to Event class?

@@ -12,8 +13,9 @@ public static void main(String[] args) throws IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String[] word = br.readLine().split(" ");
String[] word = br.readLine().split(" ",2);

Choose a reason for hiding this comment

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

i like that you store word as a String array for easier manipulation

@@ -12,8 +13,9 @@ public static void main(String[] args) throws IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String[] word = br.readLine().split(" ");
String[] word = br.readLine().split(" ",2);

Choose a reason for hiding this comment

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

would renaming word make it less vague and reflect more as a command?

Copy link

@antonlee59 antonlee59 left a comment

Choose a reason for hiding this comment

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

Overall, LGTM. Very clean code and very nice use of ternary operators. Nice abstraction and use of Inheritance to enforce the OOP principles. Good job!

Comment on lines 18 to 23
public String toString() {
return this.isDone
? "[D][X] " + this.name + " (by: " + getDate(this.deadline) + ")"
: "[D][ ] " + this.name + " (by: " + getDate(this.deadline) + ")";
}
}

Choose a reason for hiding this comment

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

Perhaps, instead of leaving the isDone logic in this toString() function, you could leave it in the Task class instead so that you dont have to retype so much code if you need to create a new Task type in the future.

Comment on lines 41 to 150
// try {
// if (word[0].equals("list")) {
// int curr = 1;
// Iterator<Task> iter = lst.iterator();
// while (iter.hasNext()) {
// System.out.println(curr + " " + iter.next());
// curr++;
// }
// word = br.readLine().strip().split(" ",2);
// } else if (word[0].equals("mark")) {
// if (word.length == 1) {
// throw new DukeException("Mark needs a number.");
// }
// if (Integer.parseInt(word[1]) > count) {
// throw new DukeException("Invalid task.");
// }
// Task t = lst.get(Integer.parseInt(word[1]) - 1);
// t.isDone = true;
// System.out.println("Task has been marked as done:\n " + t);
// word = br.readLine().split(" ",2);
// } else if (word[0].equals("unmark")) {
// if (word.length == 1) {
// throw new DukeException("Unmark needs a number.");
// }
// if (Integer.parseInt(word[1]) > count) {
// throw new DukeException("Invalid task.");
// }
// Task t = lst.get(Integer.parseInt(word[1]) - 1);
// t.isDone = false;
// System.out.println("Task has been marked as not done:\n " + t);
// word = br.readLine().split(" ",2);
// } else if (word[0].equals("todo")) {
// if (word.length == 1) {
// throw new DukeException("todo needs a description");
// }
// Task t = new Todo(word[1].strip());
// lst.add(t);
// count++;
// System.out.println("Added new todo:\n " + t + "\nNumber of tasks: " + count);
// word = br.readLine().strip().split(" ",2);
// } else if (word[0].equals("deadline")) {
// if (word.length == 1 || !word[1].contains("/by")) {
// throw new DukeException("Deadline needs a /by.");
// }
// String[] tempWord = word[1].strip().split("/by ");
// if (tempWord.length == 1) {
// throw new DukeException("/by needs a date/time.");
// }
// try {
// Task t = new Deadline(tempWord[0].strip(), tempWord[1].strip());
// lst.add(t);
// count++;
// System.out.println("Added new deadline:\n " + t + "\nNumber of tasks: " + count);
// word = br.readLine().strip().split(" ",2);
// } catch (DateTimeParseException e) {
// throw new DukeException("Date after /by needs to be in format yyyy-mm-dd");
// }
// } else if (word[0].equals("event")) {
// if (word.length == 1 || !word[1].contains("/from") || !word[1].contains("/to") ) {
// throw new DukeException("Event needs a /from and /to.");
// }
// String[] tempWord = word[1].split("/");
// String[] from = tempWord[1].split(" ",2);
// String[] to = tempWord[2].split(" ",2);
// if (from.length == 1 || to.length == 1) {
// throw new DukeException("/from and /to needs a date/time.");
// }
// try {
// Task t = new Event(tempWord[0].strip(), from[1].strip(), to[1].strip());
// lst.add(t);
// count++;
// System.out.println("Added new event:\n " + t + "\nNumber of tasks: " + count);
// word = br.readLine().strip().split(" ",2);
// } catch (DateTimeParseException e) {
// throw new DukeException("Date after /from and /to needs to be in format yyyy-mm-dd");
// }
// } else if (word[0].equals("delete")) {
// if (word.length == 1) {
// throw new DukeException("Delete needs a number.");
// }
// if (Integer.parseInt(word[1]) > count) {
// throw new DukeException("Invalid task.");
// }
// Task t = lst.remove(Integer.parseInt(word[1]) - 1);
// count--;
// System.out.println("Deleted task:\n " + t + "\nNumber of tasks: " + count);
// word = br.readLine().strip().split(" ",2);
// } else {
// throw new DukeException("Sorry I do not understand the command");
// }
// } catch (DukeException e) {
// System.out.println(e.getMessage());
// word = br.readLine().strip().split(" ",2);
// }
// }
// storeData(lst);
// System.out.println("Duke: Goodbye");
// } catch (IOException e) {
// System.out.println(e.getMessage());
// }

Choose a reason for hiding this comment

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

I suggest you to just delete all these unnecessary commented code. That is mainly the point of a version control system like git which is to undo any changes that you might not like in the future. Commenting them out and leaving them in code makes your code unnecssarily long and confusing.

Copy link

@Zhongli5712 Zhongli5712 left a comment

Choose a reason for hiding this comment

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

Overall, I found your code easy to follow, however there are still some minors details that you should notice. Well done!

Comment on lines 73 to 80
public void todo(String[] input, TaskList taskList) throws DukeException {
if (input.length == 1) {
throw new DukeException("todo needs a description");
}
Task t = new Todo(input[1].strip());
taskList.addTask(t);
System.out.println("Added new todo:\n " + t + "\nNumber of tasks: " + taskList.size());
}

Choose a reason for hiding this comment

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

should the method name be "addTodo"?

import duke.task.Task;

public class TaskList {
private ArrayList<Task> taskList;

Choose a reason for hiding this comment

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

should the name be "tasks"?

Comment on lines 14 to 37
switch (input[0]) {
case "list":
taskList.list();
break;
case "mark":
mark(input, taskList);
break;
case "unmark":
unmark(input, taskList);
break;
case "todo":
todo(input, taskList);
break;
case "deadline":
deadline(input, taskList);
break;
case "event":
event(input, taskList);
break;
case "delete":
delete(input, taskList);
break;
default:
throw new DukeException("Sorry I do not understand the command");

Choose a reason for hiding this comment

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

should the switch and case and default be on the same indentation?

}

public void event(String[] input, TaskList taskList) throws DukeException {
if (input.length == 1 || !input[1].contains("/from") || !input[1].contains("/to") ) {

Choose a reason for hiding this comment

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

should it be broken down to be three boolean variables?

Comment on lines 13 to 17
public String getFileDesc() {
return this.isDone
? "D|1|" + this.name + "|" + convertFileDate(this.deadline)
: "D|0|" + this.name + "|" + convertFileDate(this.deadline);
}

Choose a reason for hiding this comment

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

I like your break down line for easier reading

Set up JavaFX and link Duke class to GUI.

Add MainWindow.java as controller for as main GUI.

Add DialogBox.java as controller for DialogBox in GUI.

Add MainWindow.fxml and DialogBox.fxml for GUI layout and interaction
Set up JavaFX and link Duke class to GUI.

Add MainWindow.java as controller for as main GUI.

Add DialogBox.java as controller for DialogBox in GUI.

Add MainWindow.fxml and DialogBox.fxml for GUI layout and interaction
randallnhr and others added 14 commits February 12, 2023 23:45
Assertions make it easier to ensure that certain variables/ methods are
behaving as expected.

By using assertions, we can make debugging easier as assumptions are
ensured.
There are several methods that use complicated expressions.

`mark`, `unmark`, `deadline` and `delete` methods in Parser class has 2
checks in an if condition.
Abstracted the checks to 2 variables to enhance readability.

`event` method in the Parser class has 3 checks in the if condition.
Abstracted the checks to 3 variables to enhance readability.

As a step forward, let's abstract complicated checks in the conditions.
Allow users to change the /by date of deadline tasks and
/from, /to of event tasks.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants