-
Notifications
You must be signed in to change notification settings - Fork 200
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
[LimHongYao] iP #201
base: master
Are you sure you want to change the base?
[LimHongYao] iP #201
Conversation
Changed Duke's Name
Improved handling of commands by splitting user input Changed to use Tasks classes
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, the code is readable and the if statements are not deeply nested.
src/main/java/Duke.java
Outdated
boolean exit = false; | ||
while (!exit) { | ||
String input = (in.nextLine()).trim(); | ||
String inputCMD, inputItem; |
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.
Can I check what does CMD mean? If it stands for command. I think it's better to just name it as inputCommand for readibilty.
src/main/java/Duke.java
Outdated
inputCMD = input.split(" ", 2)[0]; | ||
inputItem = input.split(" ", 2)[1]; |
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.
The numbers like 2, 0, 1 might be considered magic numbers that hinder readability.
src/main/java/ToDoList.java
Outdated
} | ||
} | ||
public static void markDone (int index) { | ||
if (TaskList.get(index).getStatusIcon().equals(" ")) { |
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 this if statement necessary? I think markDone would change the status icon to "X" independent of what is originally is
src/main/java/Duke.java
Outdated
ToDoList.markDone(Integer.parseInt(inputItem)-1); | ||
System.out.println("Okay I've marked item " + inputItem + " as done:"); | ||
ToDoList.printItem(Integer.parseInt(inputItem)-1); |
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.
I like the single level of abstraction applied here. Makes things easy to follow
src/main/java/Duke.java
Outdated
System.out.println("Hi it's Anna!\nWhat do you need to do?"); | ||
Scanner in = new Scanner(System.in); | ||
|
||
boolean exit = false; |
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.
Preferably name boolean in such a way that implies it is boolean.
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.
Maybe use isExit to replace exit can imply a boolean
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.
Most the codes follow the coding standard
src/main/java/Duke.java
Outdated
System.out.println("Hi it's Anna!\nWhat do you need to do?"); | ||
Scanner in = new Scanner(System.in); | ||
|
||
boolean exit = false; |
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.
Maybe use isExit to replace exit can imply a boolean
src/main/java/ToDoList.java
Outdated
import java.util.ArrayList; | ||
|
||
public class ToDoList { | ||
private static final ArrayList<Task> TaskList = new ArrayList<>(10); |
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.
Maybe V\variable names need to be in camelCase.
src/main/java/ToDoList.java
Outdated
import java.util.ArrayList; | ||
|
||
public class ToDoList { | ||
private static final ArrayList<Task> TaskList = new ArrayList<>(10); |
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.
Maybe variable names need to be in camelCase.
src/main/java/ToDoList.java
Outdated
|
||
public class ToDoList { | ||
private static final ArrayList<Task> TaskList = new ArrayList<>(10); | ||
private static int NumTasks = 0; |
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.
Maybe variable names must be in camelCase, same problem.
src/main/java/ToDoList.java
Outdated
import java.util.ArrayList; | ||
|
||
public class ToDoList { | ||
private static final ArrayList<Task> TaskList = new ArrayList<>(10); |
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.
Maybe the size of the ArrayList should be a magic number.
added immediate prompt for missing information reworked the terrible code in getStartEnd
src/main/java/Duke.java
Outdated
public class Duke { | ||
static final int COMMAND_INDEX = 0; |
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.
Good job using constants for your numbers! You could extend that to magic strings as well!
src/main/java/Duke.java
Outdated
TaskList.viewList(); | ||
} | ||
break; | ||
|
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.
Do avoid leaving the space between each case
as per the Java Coding Standards
src/main/java/Task.java
Outdated
public String getTypeIcon() { | ||
return "NULL"; | ||
} | ||
public String taskTypeIcon() { return "[" + getTypeIcon() + "]";} |
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.
Even though these are simple 1 liners, please do still follow the proper style (aka Egyptian Style).
import java.util.ArrayList; | ||
|
||
public class TaskList { | ||
private static final ArrayList<Task> TaskList = new ArrayList<>(10); |
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.
ArrayList is a type of dynamic array and there is no need to limit your TaskList
to a size of 10 only!
System.out.println(TaskList.get(i).getTask()); | ||
} | ||
} | ||
public static void markDone (int index) { |
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.
There should not be a space between markDone
and (
. Do change this for your other methods as well :)
src/main/java/Task.java
Outdated
protected String description; | ||
protected boolean isDone; | ||
|
||
public Task(String description) { //ok to leave as public? |
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.
Yes you need to leave it as public. But do remove such comments from your code as it goes against the java coding standard. 👍
fixed minor presentation error in event
introduced some constants introduced file path printout in event of export failure
removed redundanct "add" method in Duke.java
Reformatted event and deadline displays
added search functionality
added parser class
added javadoc documentation
Renamed Duke
Added ToDoList functionality (add, mark, unmark, show list)
Given some personality