[Tham Chun Leong] iP - #87
allyfern72 wants to merge 40 commits into
Conversation
edemirkirkan
left a comment
There was a problem hiding this comment.
Looks good to merge, just a few little nits.
| public class Bao { | ||
| private static Scanner in = new Scanner(System.in); | ||
| private static Task[] tasks = new Task[100]; | ||
| private static int numTasks=0; |
There was a problem hiding this comment.
Since the 'numTasks' has a static modifier, it must belong to a task class, and should've incremented in while task was added or created, eg. on constructor.
|
|
||
| private static void addToDo(String msg){ | ||
| String description; | ||
| final int TODO_LENGTH = "todo".length(); |
There was a problem hiding this comment.
you should define these kind of constants at the beginning of the class
|
|
||
| private static void addDeadline(String msg){ | ||
| String description, dateTime; | ||
| final int DEADLINE_LENGTH = "deadline".length(); |
There was a problem hiding this comment.
you should define these kind of constants at the beginning of the class
|
|
||
| private static void addEvent(String msg){ | ||
| String description, dateTime; | ||
| final int EVENT_LENGTH = "event".length(); |
There was a problem hiding this comment.
you should define these kind of constants at the beginning of the class
| return "[D]" + | ||
| "[" + getStatusIcon() + "] " + description + | ||
| " (by: " + getDateTime() + ")"; |
There was a problem hiding this comment.
| return "[D]" + | |
| "[" + getStatusIcon() + "] " + description + | |
| " (by: " + getDateTime() + ")"; | |
| return "[D]" + super.toString() + " (by:" + getDateTime() + ")"; |
| return "[E]" + | ||
| "[" + getStatusIcon() + "] " + description + | ||
| " (at: " + getDateTime() + ")"; |
There was a problem hiding this comment.
| return "[E]" + | |
| "[" + getStatusIcon() + "] " + description + | |
| " (at: " + getDateTime() + ")"; | |
| return "[E]" + super.toString() + " (at:" + getDateTime() + ")"; |
| package Components; | ||
|
|
||
| public class Event extends Task{ | ||
| String dateTime; |
There was a problem hiding this comment.
| String dateTime; | |
| protected String dateTime; |
all of the field members of the class should be private or protected
| package Components; | ||
|
|
||
| public class Deadline extends Task{ | ||
| String dateTime; |
There was a problem hiding this comment.
| String dateTime; | |
| protected String dateTime; |
all of the field members of the class should be private or protected
| } | ||
|
|
||
| public String toString(){ | ||
| return "[T]" + "[" + getStatusIcon() + "] " + description; |
There was a problem hiding this comment.
| return "[T]" + "[" + getStatusIcon() + "] " + description; | |
| return "[T]" + super.toString(); |
Bryan-BC
left a comment
There was a problem hiding this comment.
Looks great!
Almost everything abides to the coding standard.
| } | ||
|
|
||
| public String getStatusIcon() { | ||
| return (isDone ? "X" : " "); // mark done task with X |
There was a problem hiding this comment.
I like the usage of the ternary operator, makes it look cleaner
| private static Scanner in = new Scanner(System.in); | ||
| private static Task[] tasks = new Task[100]; | ||
| private static int numTasks=0; | ||
|
|
There was a problem hiding this comment.
Any reason why you did not include a variable separator so you do not have to print the long line of underscore?
| private static String separator = "______________________________________________________________________________________"; |
|
|
||
| private static void addTask(Task task){ | ||
| System.out.println("______________________________________________________________________________________"); | ||
| tasks[numTasks++]=task; |
There was a problem hiding this comment.
I think it would be better to have a space separating the equals sign like you did in other lines.
| tasks[numTasks++]=task; | |
| tasks[numTasks++] = task; |
| } | ||
|
|
||
| public void setIsDone(boolean isDone){ | ||
| this.isDone=isDone; |
There was a problem hiding this comment.
you should use spacing before and after assignment statement
YitHien
left a comment
There was a problem hiding this comment.
Good code overall, just a few minor formatting changes. LGTM
| private static void addDeadline(String msg){ | ||
| String description, dateTime; | ||
| final int DEADLINE_LENGTH = "deadline".length(); | ||
| description = msg.substring(DEADLINE_LENGTH,msg.indexOf("/by")).trim(); |
| description = msg.substring(EVENT_LENGTH,msg.indexOf("/at")).trim(); | ||
| dateTime = msg.substring(msg.indexOf("/at")+"/at".length()).trim(); |
| return "[E]" + | ||
| "[" + getStatusIcon() + "] " + description + | ||
| " (at: " + getDateTime() + ")"; |
There was a problem hiding this comment.
Nice line breaking to prevent the line from getting too long!
| } | ||
|
|
||
| private static void markTask(String msg){ | ||
| System.out.println("______________________________________________________________________________________"); |
There was a problem hiding this comment.
You could refactor this printing into a separate method/constant since it is used a lot
| import static Constants.BaoConstants.LINE_BREAK; | ||
|
|
||
| public class Bao { | ||
| private static Scanner in = new Scanner(System.in); |
There was a problem hiding this comment.
Maybe you should consider using more descriptive names like "inScanner" for this object?
| try { | ||
| if (userInput.equalsIgnoreCase("list")) { | ||
| listTasks(); | ||
| } else if (userInput.toLowerCase().startsWith ("mark")) { |
There was a problem hiding this comment.
There is an extra space for the startsWith method.
| tasklistFile.createNewFile(); | ||
| } | ||
|
|
||
| Scanner s = new Scanner(tasklistFile); |
There was a problem hiding this comment.
Maybe a name like "scanner" would be better?
|
|
||
| static void saveTasklist(ArrayList<Task> tasks) throws IOException { | ||
| try { | ||
| FileWriter fw = new FileWriter(FILE_PATH); |
There was a problem hiding this comment.
A name like "fileWriter" would increase the readability.
|
|
||
| static void listTasks() { | ||
| for (int i = 0; i < numTasks; i++) { | ||
| System.out.println(i+1 + ". " + tasks.get(i).toString()); |
There was a problem hiding this comment.
Maybe you could make the space between operators consistent.
Level-8: Use LocalDateTime to store dates and times
Level-9: Add Find function
A-JavaDoc: Add JavaDoc comments
No description provided.