[Ho Wei Yi Stanley] iP - #99
Conversation
| } | ||
|
|
||
| public String getStatusIcon() { | ||
| return (isDone ? "\u2713" : " "); //return tick symbol if task is done |
There was a problem hiding this comment.
Perhaps this unicode can be replaced with a more expressive constant instead, so that the comment can be removed
| System.out.println("\t__________________________________________\n"); | ||
|
|
||
| ArrayList<Task> tasks = new ArrayList<Task>(); | ||
| int taskCount = 0; |
There was a problem hiding this comment.
Instead of using the taskCount variable, is it possible to use tasks.length instead, so there is one less variable to manage?
There was a problem hiding this comment.
Good idea. Fixed it already!
tehtea
left a comment
There was a problem hiding this comment.
Generally, no coding standard violations. Good job!
| this.by = by; | ||
| } | ||
|
|
||
| @Override |
There was a problem hiding this comment.
Neat use of method overriding too for each entity
| // sets a task as done | ||
| System.out.println("\tGreat job! I've marked this task as done: "); | ||
| Task task = tasks.get(taskIndex - 1); | ||
| task.markAsDone(); |
| System.out.println("\t__________________________________________\n"); | ||
|
|
||
| ArrayList<Task> tasks = new ArrayList<>(); | ||
| boolean runLoop = true; |
There was a problem hiding this comment.
Naming of boolean variable is very readable. Very good!
| this.at= at; | ||
| } | ||
|
|
||
| @Override |
There was a problem hiding this comment.
Good use of method overriding, allows Event class to inherit from parent Task class. Very good!
| // if list is empty | ||
| System.out.println("\tYour list is empty!"); | ||
| } | ||
| else { |
There was a problem hiding this comment.
If else statements should follow proper code standards! Small issue as the other statements follow them.
| System.out.println("\tWhat can I help you with?"); | ||
| System.out.println("\t__________________________________________\n"); | ||
|
|
||
| ArrayList<Task> tasks = new ArrayList<>(); |
There was a problem hiding this comment.
Collection of tasks is in plural form! Good!
lowwilliam
left a comment
There was a problem hiding this comment.
Overall good code quality! Clean and easy to understand and track!
| while (runLoop) { | ||
|
|
||
| String userInput = sc.nextLine().trim(); | ||
|
|
There was a problem hiding this comment.
No need to leave space between these
|
|
||
| public Task(String description) { | ||
| this.description = description; | ||
| this.isDone = false; |
There was a problem hiding this comment.
good use of naming and Class with super
|
|
||
| @Override | ||
| public String toString() { | ||
| return "[D]" + super.toString() + "(by: " + this.by + ")"; |
There was a problem hiding this comment.
This is a very clear structure of code, I will also apply this in mine
| System.out.println("\t__________________________________________\n"); | ||
| } else { | ||
| // adds a task to the list | ||
| System.out.println("\t------------------------------------------"); |
There was a problem hiding this comment.
I like the usage of a different form of lines, one:----- and one––––––––, it performs different meanings and let users easily understood.
|
|
||
| String userInput = sc.nextLine().trim(); | ||
|
|
||
| if (userInput.equals("bye")) { |
There was a problem hiding this comment.
Could modify so that it is not case-sensitive
| runLoop = false; | ||
| } else if (userInput.equals("list")) { | ||
| System.out.println("\t------------------------------------------"); | ||
| if (tasks.size() == 0) { |
There was a problem hiding this comment.
Good to check if the list is empty before printing out the list!
| } else { | ||
| // adds a task to the list | ||
| System.out.println("\t------------------------------------------"); | ||
| switch(userInput.split(" ")[0]) { |
There was a problem hiding this comment.
could make a method to add task make code neater!
| break; | ||
| case "event": | ||
| // adds event tasks | ||
| Task event = new Event(userInput.substring(6, userInput.indexOf("/at")), |
There was a problem hiding this comment.
userInput.indexOf("/at")+4 could be confusing
There was a problem hiding this comment.
Good work! I think you follow code naming conventions and coding standards well. I think you could work on simplifying and breaking down complicated expressions and methods; readability is the name of the game here. Additionally, consider code organisation; you could split your code into more classes, as a lot of your program's functionality seems to be happening in just one class.
|
|
||
| public Deadline(String description, String by) { | ||
| super(description); | ||
| this.by = by; |
There was a problem hiding this comment.
Consider using a more descriptive variable name that better illustrates what the variable represents.
| } | ||
|
|
||
| public String getStatusIcon() { | ||
| return (isDone ? "X" : " "); |
There was a problem hiding this comment.
Though I understand what you're doing here, from a code readability standpoint, it's best to avoid conditionals in favour of a more explicit and clear if-else statement.
|
|
||
| public static void exitProgram() { | ||
| // exits the program | ||
| System.out.println("\t------------------------------------------"); |
There was a problem hiding this comment.
If you're using this string a lot, perhaps consider storing it as a constant variable that you could re-use elegantly.
| } | ||
|
|
||
| public static void markTask(String userInput, ArrayList<Task> tasks) throws NumberFormatException, | ||
| IndexOutOfBoundsException { |
There was a problem hiding this comment.
Good that you followed wrapped-line indentation of 8 spaces!
| } else if (userInput.split(" ")[0].equalsIgnoreCase("done")) { | ||
| markTask(userInput, tasks); | ||
| } | ||
| else if (userInput.split(" ")[0].equalsIgnoreCase("delete")) { |
There was a problem hiding this comment.
Perhaps you could avoid complicated (and repeated) expressions by breaking it down into multiple lines and storing it as a variable first; I noticed the same issue in a few other classes too, and it would help a reader understand your code better!
| System.out.println("\t__________________________________________\n"); | ||
| } | ||
|
|
||
| public static void addTask(String userInput, ArrayList<Task> tasks) throws StringIndexOutOfBoundsException { |
There was a problem hiding this comment.
This method is really long; consider breaking it down into smaller methods that would also make it easier for you to debug your own work. Maybe, upon doing so, you could move some of those methods to their relevant class (i.e. Deadline class, Event class, etc) to enhance code organisation
No description provided.