Conversation
wentuoc
left a comment
There was a problem hiding this comment.
Overall good readability with a clear and logial sequence! Just a few nits to pick. Good job :)
src/main/java/Main/Roboast.java
Outdated
|
|
||
| while (!input.equals("bye")) { | ||
|
|
||
| int space = input.indexOf(' '); |
There was a problem hiding this comment.
Would a more descriptive variable name such as spaceIndex be better?
src/main/java/Main/Roboast.java
Outdated
|
|
||
| private final ArrayList<Item> itemList = new ArrayList<Item>(); | ||
|
|
||
| public void start() { |
There was a problem hiding this comment.
I like the use of abstraction to manage the different stages of the program!
src/main/java/Item/Deadline.java
Outdated
|
|
||
| public Deadline(String name, boolean done){ | ||
| super(name, done); | ||
| String newname = name.replace("/by","(by:"); |
There was a problem hiding this comment.
Should the by field be extracted out and stored as a separate attribute so that it can be accessed and modified when necessary? (e.g. say if I want to change the due date)
src/main/java/Item/Item.java
Outdated
|
|
||
| public class Item { | ||
| protected String name; | ||
| protected boolean done; |
There was a problem hiding this comment.
Would it be better to use isDone as the name for this boolean variable?
src/main/java/Main/Roboast.java
Outdated
| while (!input.equals("bye")) { | ||
|
|
||
| int space = input.indexOf(' '); | ||
| boolean foundSpace = (space > 0); |
There was a problem hiding this comment.
I like the use of these boolean variables to simplify the expression in the if condition later on!
src/main/java/Main/Roboast.java
Outdated
| while (i < itemList.size()) { | ||
| if (itemList.get(i).isDone()){ | ||
| itemList.remove(i); | ||
| } |
There was a problem hiding this comment.
Can consider adhering to K&R style for curly braces
src/main/java/Item/Item.java
Outdated
| package Item; | ||
|
|
||
| public class Item { | ||
| protected String name; |
There was a problem hiding this comment.
Could've considered using a more descriptive name for the String variable
src/main/java/Item/Item.java
Outdated
|
|
||
| @Override | ||
| public String toString() { | ||
| if (done){ |
There was a problem hiding this comment.
Perhaps could've used a ternary operator instead?
src/main/java/Main/Roboast.java
Outdated
|
|
||
| public class Roboast { | ||
| private static final String BOT_NAME = "Roboast"; | ||
| private static final String LINE = "_".repeat(50); |
There was a problem hiding this comment.
I like how instead of typing the "_" out, you just used the repeat method.
src/main/java/Main/Roboast.java
Outdated
| String content = input.substring(space+1); | ||
| if (command.equals("setDone")){ | ||
| mark(content, true); | ||
| } |
There was a problem hiding this comment.
Maybe you should be more consistent with the spacing before the "{" if you want to add a space before it or not.
sevenseasofbri
left a comment
There was a problem hiding this comment.
Good job so far! You might need to work on following the layout accoridng to the java coding standard though.
| @@ -0,0 +1,57 @@ | |||
| package diskIO; | |||
There was a problem hiding this comment.
From java coding standard: Names representing packages should be in all lower case.
Consider making the package name something like storage or disk.io
src/main/java/item/Deadline.java
Outdated
| super(name, done); | ||
| String newname = name.replace("/by","(by:"); | ||
| int byIndex = newname.indexOf("(by:"); | ||
|
|
||
| try { | ||
| deadline = newname.substring(byIndex + 5, newname.length() - 1); | ||
| } | ||
| catch (StringIndexOutOfBoundsException e) { | ||
| deadline = null; | ||
| } | ||
|
|
||
|
|
||
| if (!name.equals(newname)){ | ||
| newname = newname + ")"; | ||
| } | ||
| super.setItemName(newname); | ||
| super.itemType = "Deadline"; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(){ | ||
| if (super.isDone){ | ||
| return "[D][X] " + super.itemName; | ||
| } | ||
| else{ | ||
| return "[D][ ] " + super.itemName; |
There was a problem hiding this comment.
Perhaps avoid the usage of magic literals by using constants or vars.
| try { | ||
| eventStartTime = newname.substring(newname.indexOf("(from:") + 6, newname.indexOf("to:") - 1); | ||
| eventEndTime = newname.substring(newname.indexOf("to:") + 4);; | ||
| } |
There was a problem hiding this comment.
try-catch blocks should ideally be of the form:
try {
statements;
} catch (Exception exception) {
statements;
}| if (super.isDone){ | ||
| return "[E][X] " + super.itemName; | ||
| } | ||
| else{ | ||
| return "[E][ ] " + super.itemName; | ||
| } |
There was a problem hiding this comment.
if-else clauses should be of the form:
if (condition) {
statements;
} else {
statements;
}| @@ -0,0 +1,50 @@ | |||
| package item; | |||
|
|
|||
| public class Event extends Item{ | |||
There was a problem hiding this comment.
| public class Event extends Item{ | |
| public class Event extends Item { |
| this.itemList = itemList; | ||
| } | ||
|
|
||
| public void action(String input) throws RoboastException { |
There was a problem hiding this comment.
This method is over >30 LOC. Consider refactoring the inner-levels of code into other methods.
There was a problem hiding this comment.
Additionally, a method is supposed to be a verb. As such action does not fit this description. Consider calling it applyAction or something.
| try { | ||
| command = input.substring(0, spaceIndex); | ||
| content = input.substring(spaceIndex + 1); | ||
| } | ||
| catch (IndexOutOfBoundsException e) { | ||
| command = input; | ||
| content = ""; | ||
| } | ||
| if (command.equals("mark")) { | ||
| mark(content, true); | ||
| } | ||
| else if (command.equals("unmark")) { | ||
| mark(content, false); | ||
| } | ||
| else if (command.equals("todo")) { | ||
| addTodo(content); | ||
| } | ||
| else if (command.equals("deadline")) { | ||
| addDeadlines(content); | ||
| } | ||
| else if (command.equals("event")) { | ||
| addEvents(content); | ||
| } | ||
| else if (command.equals("list")) { | ||
| showItemList(); | ||
| } | ||
| else if (command.equals("deleteAll")) { | ||
| deleteAll(); | ||
| } | ||
| else if (command.equals("delete")) { | ||
| delete(content); | ||
| } | ||
| else { | ||
| throw new RoboastException("Invalid command"); | ||
| } |
There was a problem hiding this comment.
Again, the layout of these clauses needs to be adjusted (like mentioned before)
if (condition) {
statements;
} else if (condition) {
statements;
} else {
statements;
}| public void addDeadlines(String content) { | ||
| if (content.isEmpty()){ | ||
| showAddEmptyError(); | ||
| return; | ||
| } | ||
| System.out.println(LINE); | ||
| Item item = new Deadline(content, false); | ||
| itemList.add(item); | ||
| System.out.println("added: " + item.getItemName() + "\n" + | ||
| "You now have " + itemList.size() + " tasks\n" + LINE); | ||
| } | ||
|
|
||
| public void addEvents(String content) { |
There was a problem hiding this comment.
The functions refer to events and deadline in plural, but the functions themselves add only 1 event or 1 deadline at a time. Consider naming them addDeadline and addEvent instead.
src/main/java/item/ItemManage.java
Outdated
|
|
||
| } | ||
|
|
||
| public void mark(String content, boolean isDone) { |
There was a problem hiding this comment.
What is exaclt meant by variable content? Is it the input from the user? Consider naming it something else more intuitive.
| if (itemList.get(i).isDone()){ | ||
| itemList.remove(i); | ||
| } | ||
| else{ |
No description provided.