CerIsaiah iP#81
Conversation
| System.out.println("Congrats I marked this class as done : " + markedTask.getDescription()); | ||
| markedTask.isDone = true; | ||
| System.out.println("Congrats I marked this class as done : " + markedTask.getDescription()); | ||
| } catch (Exception ArrayIndexOutOfBoundsException){ |
There was a problem hiding this comment.
should you catch the exception during the input phase? Check if 0 < user input index < num of items + 1
| System.out.println(todo.getDescription()); | ||
| tasks.add(todo); | ||
|
|
||
| } catch (Exception e) { |
There was a problem hiding this comment.
what types of errors are expected? can the exception catch be more specific?
| @@ -0,0 +1,12 @@ | |||
| public class Todo extends Task{ | |||
| protected String by; | |||
There was a problem hiding this comment.
should this variable be marked as private instead of protected? its the final class in the inheritance chain
AlWo223
left a comment
There was a problem hiding this comment.
Nice work, I have only suggested a small change to improve coding style
| if (input.equals("list")){ | ||
| int numOfTasks = 0; | ||
|
|
||
| for (Task task: tasks){ | ||
| numOfTasks++; | ||
| System.out.println(numOfTasks + ": " + task.getDescription()); | ||
| } | ||
|
|
||
| } else if (input.toLowerCase().startsWith("mark ")){ | ||
| String[] parts = input.split(" "); | ||
|
|
||
| int taskNum = Integer.parseInt(parts[1]); | ||
| try { | ||
| Task markedTask = tasks.get(taskNum - 1); | ||
|
|
||
| markedTask.isDone = true; | ||
| System.out.println("Congrats I marked this class as done : " + markedTask.getDescription()); | ||
| } catch (Exception ArrayIndexOutOfBoundsException){ | ||
| System.out.println("That task doesnt exist"); | ||
| } | ||
|
|
||
| } else if (input.toLowerCase().startsWith("unmark ")) { | ||
| String[] parts = input.split(" "); | ||
|
|
||
| int taskNum = Integer.parseInt(parts[1]); | ||
| tasks.get(taskNum - 1).isDone = false; | ||
|
|
||
| try { | ||
| Task unmarkedTask = tasks.get(taskNum - 1); | ||
|
|
||
| unmarkedTask.isDone = false; | ||
| System.out.println("I unmarked this class as done: " + unmarkedTask.getDescription()); | ||
| } catch (Exception ArrayIndexOutOfBoundsException){ | ||
| System.out.println("That task doesnt exist"); | ||
| } | ||
| } else if (input.toLowerCase().startsWith("deadline")){ | ||
| try { | ||
| String[] toDoSplit = input.split("/"); | ||
| //First part is task, and last is when by | ||
| String desc = toDoSplit[0].substring(9).trim(); // removes "deadline | ||
| Deadline deadline = new Deadline(desc, toDoSplit[1].trim()); | ||
| System.out.println(deadline.getDescription()); | ||
|
|
||
| tasks.add(deadline); | ||
|
|
||
| } catch (Exception ArrayIndexOutOfBoundsException){ | ||
| System.out.println("Put a / after your task if you want to add a todo"); | ||
| } | ||
|
|
||
|
|
||
| } else if (input.toLowerCase().startsWith("event")){ | ||
| try { | ||
| String[] toDoSplit = input.split("/"); |
There was a problem hiding this comment.
Should you use a switch() statement instead of multiple if else?
| break; | ||
| } | ||
|
|
||
| if (input.equals("list")){ |
There was a problem hiding this comment.
Is there a reason why you don't use toLowerCase() for this specific command?
YongbinWang
left a comment
There was a problem hiding this comment.
Overall good work. Just some minor nitpicks from my part. Keep up the good work!
| String start; | ||
| String end; |
There was a problem hiding this comment.
Consider adding in access modifiers and not leave it to default.
|
|
||
| } else if (input.toLowerCase().startsWith("deadline")){ | ||
| try { | ||
| String[] toDoSplit = input.split("/"); |
There was a problem hiding this comment.
Consider changing the variable name to a more suitable plural name.
No description provided.