-
Notifications
You must be signed in to change notification settings - Fork 83
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
[Tham Chun Leong] iP #87
base: master
Are you sure you want to change the base?
Conversation
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.
Looks good to merge, just a few little nits.
src/main/java/Bao.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/main/java/Bao.java
Outdated
|
||
private static void addToDo(String msg){ | ||
String description; | ||
final int TODO_LENGTH = "todo".length(); |
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.
you should define these kind of constants at the beginning of the class
src/main/java/Bao.java
Outdated
|
||
private static void addDeadline(String msg){ | ||
String description, dateTime; | ||
final int DEADLINE_LENGTH = "deadline".length(); |
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.
you should define these kind of constants at the beginning of the class
src/main/java/Bao.java
Outdated
|
||
private static void addEvent(String msg){ | ||
String description, dateTime; | ||
final int EVENT_LENGTH = "event".length(); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "[D]" + | |
"[" + getStatusIcon() + "] " + description + | |
" (by: " + getDateTime() + ")"; | |
return "[D]" + super.toString() + " (by:" + getDateTime() + ")"; |
src/main/java/Components/Event.java
Outdated
return "[E]" + | ||
"[" + getStatusIcon() + "] " + description + | ||
" (at: " + getDateTime() + ")"; |
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.
return "[E]" + | |
"[" + getStatusIcon() + "] " + description + | |
" (at: " + getDateTime() + ")"; | |
return "[E]" + super.toString() + " (at:" + getDateTime() + ")"; |
src/main/java/Components/Event.java
Outdated
package Components; | ||
|
||
public class Event extends Task{ | ||
String dateTime; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String dateTime; | |
protected String dateTime; |
all of the field members of the class should be private or protected
src/main/java/Components/Todo.java
Outdated
} | ||
|
||
public String toString(){ | ||
return "[T]" + "[" + getStatusIcon() + "] " + description; |
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.
return "[T]" + "[" + getStatusIcon() + "] " + description; | |
return "[T]" + super.toString(); |
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.
Looks great!
Almost everything abides to the coding standard.
src/main/java/Components/Task.java
Outdated
} | ||
|
||
public String getStatusIcon() { | ||
return (isDone ? "X" : " "); // mark done task with X |
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 usage of the ternary operator, makes it look cleaner
src/main/java/Bao.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 = "______________________________________________________________________________________"; |
src/main/java/Bao.java
Outdated
|
||
private static void addTask(Task task){ | ||
System.out.println("______________________________________________________________________________________"); | ||
tasks[numTasks++]=task; |
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 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; |
src/main/java/Components/Task.java
Outdated
} | ||
|
||
public void setIsDone(boolean isDone){ | ||
this.isDone=isDone; |
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.
you should use spacing before and after assignment statement
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 code overall, just a few minor formatting changes. LGTM
src/main/java/Bao.java
Outdated
private static void addDeadline(String msg){ | ||
String description, dateTime; | ||
final int DEADLINE_LENGTH = "deadline".length(); | ||
description = msg.substring(DEADLINE_LENGTH,msg.indexOf("/by")).trim(); |
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.
You could simplify this expression!
src/main/java/Bao.java
Outdated
description = msg.substring(EVENT_LENGTH,msg.indexOf("/at")).trim(); | ||
dateTime = msg.substring(msg.indexOf("/at")+"/at".length()).trim(); |
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.
You could simplify these expressions!
src/main/java/Components/Event.java
Outdated
return "[E]" + | ||
"[" + getStatusIcon() + "] " + description + | ||
" (at: " + getDateTime() + ")"; |
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 line breaking to prevent the line from getting too long!
src/main/java/Bao.java
Outdated
} | ||
|
||
private static void markTask(String msg){ | ||
System.out.println("______________________________________________________________________________________"); |
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.
You could refactor this printing into a separate method/constant since it is used a lot
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.
Readable code with minor issues.
src/main/java/Managers/Bao.java
Outdated
import static Constants.BaoConstants.LINE_BREAK; | ||
|
||
public class Bao { | ||
private static Scanner in = new Scanner(System.in); |
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 you should consider using more descriptive names like "inScanner" for this object?
src/main/java/Managers/Bao.java
Outdated
try { | ||
if (userInput.equalsIgnoreCase("list")) { | ||
listTasks(); | ||
} else if (userInput.toLowerCase().startsWith ("mark")) { |
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 is an extra space for the startsWith method.
tasklistFile.createNewFile(); | ||
} | ||
|
||
Scanner s = new Scanner(tasklistFile); |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.