Skip to content

[Tham Chun Leong] iP - #87

Open
allyfern72 wants to merge 40 commits into
nus-cs2113-AY2122S2:masterfrom
allyfern72:master
Open

allyfern72 wants to merge 40 commits into
nus-cs2113-AY2122S2:masterfrom
allyfern72:master

Conversation

@allyfern72

Copy link
Copy Markdown

No description provided.

@edemirkirkan edemirkirkan left a comment

Copy link
Copy Markdown

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.

Comment thread 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;

Copy link
Copy Markdown

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.

Comment thread src/main/java/Bao.java Outdated

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

Copy link
Copy Markdown

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 thread src/main/java/Bao.java Outdated

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

Copy link
Copy Markdown

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 thread src/main/java/Bao.java Outdated

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

Copy link
Copy Markdown

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 thread src/main/java/Components/Deadline.java Outdated
Comment on lines +16 to +18
return "[D]" +
"[" + getStatusIcon() + "] " + description +
" (by: " + getDateTime() + ")";

Copy link
Copy Markdown

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 thread src/main/java/Components/Event.java Outdated
Comment on lines +16 to +18
return "[E]" +
"[" + getStatusIcon() + "] " + description +
" (at: " + getDateTime() + ")";

Copy link
Copy Markdown

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() + ")";

Comment thread src/main/java/Components/Event.java Outdated
package Components;

public class Event extends Task{
String dateTime;

Copy link
Copy Markdown

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

Comment thread src/main/java/Components/Deadline.java Outdated
package Components;

public class Deadline extends Task{
String dateTime;

Copy link
Copy Markdown

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

Comment thread src/main/java/Components/Todo.java Outdated
}

public String toString(){
return "[T]" + "[" + getStatusIcon() + "] " + description;

Copy link
Copy Markdown

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

@Bryan-BC Bryan-BC left a comment

Copy link
Copy Markdown

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.

Comment thread src/main/java/Components/Task.java Outdated
}

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

Copy link
Copy Markdown

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

Comment thread 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;

Copy link
Copy Markdown

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 = "______________________________________________________________________________________";

Comment thread src/main/java/Bao.java Outdated

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

Copy link
Copy Markdown

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;

Comment thread src/main/java/Components/Task.java Outdated
}

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

Copy link
Copy Markdown

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

@YitHien YitHien left a comment

Copy link
Copy Markdown

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

Comment thread 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();

Copy link
Copy Markdown

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 thread src/main/java/Bao.java Outdated
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
Copy Markdown

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 thread src/main/java/Components/Event.java Outdated
Comment on lines +16 to +18
return "[E]" +
"[" + getStatusIcon() + "] " + description +
" (at: " + getDateTime() + ")";

Copy link
Copy Markdown

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!

Comment thread src/main/java/Bao.java Outdated
}

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

Copy link
Copy Markdown

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

@Mick609 Mick609 left a comment

Copy link
Copy Markdown

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.

Comment thread src/main/java/Managers/Bao.java Outdated
import static Constants.BaoConstants.LINE_BREAK;

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

Copy link
Copy Markdown

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?

Comment thread src/main/java/Managers/Bao.java Outdated
try {
if (userInput.equalsIgnoreCase("list")) {
listTasks();
} else if (userInput.toLowerCase().startsWith ("mark")) {

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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