Skip to content

[TrungBui32] iP#112

Open
TrungBui32 wants to merge 25 commits into
nus-cs2113-AY2425S1:masterfrom
TrungBui32:master
Open

[TrungBui32] iP#112
TrungBui32 wants to merge 25 commits into
nus-cs2113-AY2425S1:masterfrom
TrungBui32:master

Conversation

@TrungBui32

Copy link
Copy Markdown

No description provided.

@Yisoong Yisoong 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 overall but you might want to rename some of your variables for greater clarity. Good Job !!

Comment thread src/main/java/Poirot.java Outdated
private static int last_index = 0;

public static void echo(String msg) {
System.out.println("____________________________________________________________\n");

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 noticed that this was repeated many times. Perhaps it would be good to use a utility function to print the horizontal lines instead.

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

public class Poirot {
private static Task[] list_actions = new Task[100];
private static int last_index = 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.

Perhaps it would be better to use lastIndex instead of last_index.

Comment thread src/main/java/Poirot.java Outdated
System.out.println("Hello! I'm POIROT\n");
System.out.println("What can I do for you?");
System.out.println("____________________________________________________________\n");
boolean working = true;

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 this is a boolean, it might be better to call it "isWorking".

Comment thread src/main/java/Poirot.java Outdated
System.out.println("____________________________________________________________\n");
}

public static void add(Task action) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"add" is a bit ambiguous. It might be better to use "addTask" instead.

@TPH777 TPH777 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.

Coding standards and code quality is not strictly followed, improvements can be made

Comment thread src/main/java/Poirot.java Outdated
private static int last_index = 0;

public static void echo(String msg) {
System.out.println("____________________________________________________________\n");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Abstracting the printing of divider to a function will improve readability

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

public class Poirot {
private static Task[] list_actions = new Task[100];
private static int last_index = 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.

size may be a better name than last_index

Comment thread src/main/java/Poirot.java Outdated
import java.util.Scanner;

public class Poirot {
private static Task[] list_actions = new Task[100];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use camelCase for variables, E.g. listActions, but a better name will be tasks

Comment thread src/main/java/Poirot.java Outdated
} else {
System.out.println("____________________________________________________________\n");
for (int i = 0; i < last_index; i++) {
System.out.println((i + 1) + ".[" + list_actions[i].getStatusIcon() + "]" + list_actions[i].getDescription());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Abstract this to a function and give variable names for list_actions[i].getStatusIcon() and list_actions[i].getDescription to improve code readability

Comment thread src/main/java/Poirot.java Outdated
System.out.println("____________________________________________________________\n");
break;
case "unmark":
int y = Integer.parseInt(list_input[1]) - 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Set a variable for list_input[1] as it is unclear what is that

Comment thread src/main/java/Poirot.java Outdated
System.out.println("____________________________________________________________\n");
break;
case "unmark":
int y = Integer.parseInt(list_input[1]) - 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use a better name instead of y

@Mahesh1772 Mahesh1772 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 job!

The code looks clean and solid. Try to make use of inheritance even more in your code as OOP make coding more scalable and easier to manage. Consider adding JavaDocs in the future commits

Comment thread src/main/java/Deadline.java Outdated
}
@Override
public String toFileString() {
return "D | " + (isDone ? "1" : "0") + " | " + description + " | " + by;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider adding the description in the parent classes toFIleString() to make full use of the inheritance principles

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

@Override
public String toString() {
return "[E][" + getStatusIcon() + "] " + description + " (from: " + from + " to: " + to + ")";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider adding the description in the parent classes toFIleString() to make full use of the inheritance principles

Comment thread src/main/java/Poirot.java Outdated
public static final String LINE = "____________________________________________________________\n";
private static Task[] tasks = new Task[100];
private static final String FILE_PATH = "./data/duke.txt";
private static int last_index = 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.

Consider naming the variables with more than one word in camelCase

Comment thread src/main/java/Poirot.java Outdated
@@ -0,0 +1,204 @@
import java.io.*;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Try not to use the * to import everything. Instead explicitly import what is needed.

Comment thread src/main/java/Task.java
Comment on lines +18 to +19
public abstract String toString();
public abstract String toFileString();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider making then non abstract methods, as they can be easily utilized by sub-classes. As such, Task could not be a abstract class.

Comment thread src/main/java/Poirot.java Outdated
Comment on lines +134 to +151
tasks[x].setDone(true);
System.out.println(LINE);
System.out.println("Nice! I've marked this task as done:\n");
System.out.print("[" + tasks[x].getStatusIcon() + "] ");
System.out.println(tasks[x].getDescription());
System.out.println(LINE);
saveTasksToFile(); // Save the task after marking it
break;
case "unmark":
validateTaskNumber(list_input);
int y = Integer.parseInt(list_input[1]) - 1;
tasks[y].setDone(false);
System.out.println(LINE);
System.out.println("OK, I've marked this task as not done yet:\n");
System.out.print("[" + tasks[y].getStatusIcon() + "] ");
System.out.println(tasks[y].getDescription());
System.out.println(LINE);
saveTasksToFile();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider saving the string formatted with the current isDone in a separate method inside Task class to reduce duplicate lines of code

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

boolean working = true;
Scanner scan = new Scanner(System.in);
while (working) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider doing a saving changes to file at the end of each iteration, as such avoiding to call it every time something is changed, reduce duplicate lines

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.

4 participants