-
Notifications
You must be signed in to change notification settings - Fork 78
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
CerIsaiah iP #81
base: master
Are you sure you want to change the base?
CerIsaiah iP #81
Conversation
src/main/java/Duke.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should you catch the exception during the input phase? Check if 0 < user input index < num of items + 1
src/main/java/Duke.java
Outdated
System.out.println(todo.getDescription()); | ||
tasks.add(todo); | ||
|
||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this variable be marked as private instead of protected? its the final class in the inheritance chain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, I have only suggested a small change to improve coding style
src/main/java/Duke.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you use a switch() statement instead of multiple if else?
src/main/java/Duke.java
Outdated
break; | ||
} | ||
|
||
if (input.equals("list")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why you don't use toLowerCase() for this specific command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding in access modifiers and not leave it to default.
src/main/java/Duke.java
Outdated
|
||
} else if (input.toLowerCase().startsWith("deadline")){ | ||
try { | ||
String[] toDoSplit = input.split("/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider changing the variable name to a more suitable plural name.
No description provided.