Skip to content
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

Open
wants to merge 40 commits into
base: master
Choose a base branch
from

Conversation

allyfern72
Copy link

No description provided.

Copy link

@edemirkirkan edemirkirkan left a 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.

public class Bao {
private static Scanner in = new Scanner(System.in);
private static Task[] tasks = new Task[100];
private static int numTasks=0;

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.


private static void addToDo(String msg){
String description;
final int TODO_LENGTH = "todo".length();

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


private static void addDeadline(String msg){
String description, dateTime;
final int DEADLINE_LENGTH = "deadline".length();

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


private static void addEvent(String msg){
String description, dateTime;
final int EVENT_LENGTH = "event".length();

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

Comment on lines 16 to 18
return "[D]" +
"[" + getStatusIcon() + "] " + description +
" (by: " + getDateTime() + ")";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "[D]" +
"[" + getStatusIcon() + "] " + description +
" (by: " + getDateTime() + ")";
return "[D]" + super.toString() + " (by:" + getDateTime() + ")";

Comment on lines 16 to 18
return "[E]" +
"[" + getStatusIcon() + "] " + description +
" (at: " + getDateTime() + ")";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "[E]" +
"[" + getStatusIcon() + "] " + description +
" (at: " + getDateTime() + ")";
return "[E]" + super.toString() + " (at:" + getDateTime() + ")";

package Components;

public class Event extends Task{
String dateTime;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "[T]" + "[" + getStatusIcon() + "] " + description;
return "[T]" + super.toString();

Copy link

@Bryan-BC Bryan-BC left a 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.

}

public String getStatusIcon() {
return (isDone ? "X" : " "); // mark done task with X
Copy link

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

private static Scanner in = new Scanner(System.in);
private static Task[] tasks = new Task[100];
private static int numTasks=0;

Copy link

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?

Suggested change
private static String separator = "______________________________________________________________________________________";


private static void addTask(Task task){
System.out.println("______________________________________________________________________________________");
tasks[numTasks++]=task;
Copy link

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.

Suggested change
tasks[numTasks++]=task;
tasks[numTasks++] = task;

}

public void setIsDone(boolean isDone){
this.isDone=isDone;

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

Copy link

@YitHien YitHien left a 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

private static void addDeadline(String msg){
String description, dateTime;
final int DEADLINE_LENGTH = "deadline".length();
description = msg.substring(DEADLINE_LENGTH,msg.indexOf("/by")).trim();
Copy link

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!

Comment on lines 48 to 49
description = msg.substring(EVENT_LENGTH,msg.indexOf("/at")).trim();
dateTime = msg.substring(msg.indexOf("/at")+"/at".length()).trim();
Copy link

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!

Comment on lines 16 to 18
return "[E]" +
"[" + getStatusIcon() + "] " + description +
" (at: " + getDateTime() + ")";
Copy link

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!

}

private static void markTask(String msg){
System.out.println("______________________________________________________________________________________");
Copy link

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

Copy link

@Mick609 Mick609 left a 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.

import static Constants.BaoConstants.LINE_BREAK;

public class Bao {
private static Scanner in = new Scanner(System.in);
Copy link

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?

try {
if (userInput.equalsIgnoreCase("list")) {
listTasks();
} else if (userInput.toLowerCase().startsWith ("mark")) {
Copy link

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);
Copy link

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);
Copy link

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());
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants