Conversation
jaysmyname
left a comment
There was a problem hiding this comment.
Overall good coding standard practices!
Just remember to import classes explicitly instead of using *
src/main/java/Gary.java
Outdated
| @@ -0,0 +1,98 @@ | |||
| import java.sql.Array; | |||
| import java.util.*; | |||
There was a problem hiding this comment.
Shouldn't imported classes be listed explicitly?
src/main/java/Gary.java
Outdated
| System.out.println("Bye, hope you stay productive!\n"); | ||
| } | ||
|
|
||
| public static void printList(int type, ArrayList<Task> item) { |
There was a problem hiding this comment.
Perhaps the variable name should be in plural form for ArrayList?
src/main/java/Task.java
Outdated
| @@ -0,0 +1,25 @@ | |||
| import java.util.*; | |||
There was a problem hiding this comment.
Shouldn't imported classes be listed explicitly?
src/main/java/Gary.java
Outdated
| } else if (nxt.equals("mark")) { | ||
| System.out.println("which tasks have you completed? e.g. 2 3"); | ||
| String nums = sc.nextLine(); | ||
| String[] first = nums.split(" "); | ||
| int i = 0; | ||
| for (String str : first) { | ||
| items.get(Integer.parseInt(first[i]) - 1).toMark(); | ||
| i++; | ||
| } | ||
| Gary.printList(2, items); |
There was a problem hiding this comment.
I like that you enabled multi-step commands!
jetrz
left a comment
There was a problem hiding this comment.
Generally well written code! Minor nitpicks on documentation, but otherwise code implements OOP concepts effectively, and is clean and readable!
src/main/java/Deadlines.java
Outdated
| @@ -0,0 +1,13 @@ | |||
| public class Deadlines extends Task { | |||
| String date; | |||
There was a problem hiding this comment.
It would be good to have an access modifier for these fields. Same comment for Event.
src/main/java/Gary.java
Outdated
| if (nxt.equals("list")) { | ||
| Gary.printList(1, items); | ||
| } else if (nxt.equals("mark")) { | ||
| System.out.println("which tasks have you completed? e.g. 2 3"); | ||
| String nums = sc.nextLine(); | ||
| String[] first = nums.split(" "); | ||
| int i = 0; | ||
| for (String str : first) { | ||
| items.get(Integer.parseInt(first[i]) - 1).toMark(); | ||
| i++; | ||
| } | ||
| Gary.printList(2, items); | ||
|
|
||
| } else if (nxt.equals("unmark")) { | ||
| System.out.println("made some mistakes?"); | ||
| String nums = sc.nextLine(); | ||
| String[] first = nums.split(" "); | ||
| int k = 0; | ||
| for (String str : first) { | ||
| items.get(Integer.parseInt(first[k]) - 1).toUnmark(); | ||
| k++; | ||
| } | ||
| } else if (nxt.equals("delete")) { | ||
| System.out.println("Please key in what you would like to remove in descending order!"); | ||
| try { | ||
| String nums = sc.nextLine(); | ||
| String[] first = nums.split(" "); | ||
| int k = 0; | ||
| for (String str : first) { | ||
| items.remove(Integer.parseInt(first[k]) - 1); | ||
| k++; | ||
| } | ||
| Gary.printList(2, items); | ||
| } catch (IndexOutOfBoundsException e) { | ||
| System.out.println("Ah please enter a valid number or sequence e.g. 5 3 1"); | ||
| } | ||
|
|
||
| } else { | ||
| String[] type = nxt.split(" "); | ||
| String theTask = type[0]; | ||
| try { | ||
| if (!theTask.equals("todo") && !theTask.equals("event") && !theTask.equals("deadline")) { | ||
| throw new GaryException(nxt); // invalid input | ||
| } | ||
| } catch (GaryException e) { | ||
| e.GaryError(); | ||
| } | ||
|
|
||
| try { | ||
| switch (theTask) { | ||
| case "todo": | ||
| items.add(new ToDo(nxt.substring(5))); | ||
| break; | ||
| case "event": | ||
| String[] e = nxt.split("/", 5); | ||
| items.add(new Event(e[0].substring(6), e[1])); | ||
| break; | ||
| case "deadline": | ||
| String[] d = nxt.split("/", 5); | ||
| items.add(new Deadlines(d[0].substring(9), d[1])); | ||
| break; | ||
| } | ||
| } catch (StringIndexOutOfBoundsException e) { | ||
| System.out.println("Ah please enter a valid description e.g. task_type name / date"); | ||
| } | ||
| } | ||
| nxt = sc.nextLine(); // continue getting inputs | ||
| } | ||
| System.out.println("Bye, hope you stay productive!\n"); |
src/main/java/Task.java
Outdated
| public String toString() { | ||
| String done = this.isDone ? "X" : " "; | ||
| return "[" + done + "] " + this.task; | ||
| } |
There was a problem hiding this comment.
toString is abstracted well for Task and its children classes!
src/main/java/GaryException.java
Outdated
| public class GaryException extends Exception { | ||
| // represent exceptions specific to Gary | ||
| // int err; | ||
| String msg; | ||
|
|
||
| public GaryException(String msg) { | ||
| // this.err = err; | ||
| this.msg = msg; | ||
| } | ||
|
|
||
| public void GaryError() { | ||
| System.out.printf("Sorry, what is %s ?\n", this.msg); | ||
| } | ||
| } |
There was a problem hiding this comment.
Would be useful to add javadocs documentation for custom exceptions!
* branch-Level-8: add dates and times # Conflicts: # src/main/java/Gary.java
Use GFMD in the PR description
* 'master' of https://github.com/vanessaxuuan/ip: Update IP description
* commit 'd8398594b7bc43da5eb865321c5a50cec4b3923d': Add Gradle support
Special cases such as, * empty user input * operating on an empty to-do list should be handled specially to prevent errors Let's add assertions to functions that handle Gary's response
Group classes into packages base on their functionalities for easier management. Let's move related classes into packages such as, * gary.task * gary.ui * gary.gui * gary.exception
Standardise code naming, layout, statements and comments Add relative file path that works on both Unix and Windows
Branch a code quality
* 'master' of https://github.com/vanessaxuuan/ip: Improve code quality Rename packages
Add assert features to document important assumptions
* 'master' of https://github.com/vanessaxuuan/ip: Add assert features to document important assumptions
Let's, * Change display images * Add welcome message
* branch-better-GUI: Finalize GUI
fit-for-purpose
* 'master' of https://github.com/vanessaxuuan/ip: Update README.md Update README.md Update README.md Update README.md Update README.md Update User Guide Update README.md Add User Guide Add a representative screenshot of Gary
GARY
Gary frees your mind of having to remember things you need to do. It's,
FASTSUPER FAST to useAll you need to do is,
And it is FREE!
Features:
If you Java programmer, you can use it to practice Java too. Here's the main method: