[TrungBui32] iP#112
Conversation
Yisoong
left a comment
There was a problem hiding this comment.
Looks good overall but you might want to rename some of your variables for greater clarity. Good Job !!
| private static int last_index = 0; | ||
|
|
||
| public static void echo(String msg) { | ||
| System.out.println("____________________________________________________________\n"); |
There was a problem hiding this comment.
I noticed that this was repeated many times. Perhaps it would be good to use a utility function to print the horizontal lines instead.
|
|
||
| public class Poirot { | ||
| private static Task[] list_actions = new Task[100]; | ||
| private static int last_index = 0; |
There was a problem hiding this comment.
Perhaps it would be better to use lastIndex instead of last_index.
| System.out.println("Hello! I'm POIROT\n"); | ||
| System.out.println("What can I do for you?"); | ||
| System.out.println("____________________________________________________________\n"); | ||
| boolean working = true; |
There was a problem hiding this comment.
Since this is a boolean, it might be better to call it "isWorking".
| System.out.println("____________________________________________________________\n"); | ||
| } | ||
|
|
||
| public static void add(Task action) { |
There was a problem hiding this comment.
"add" is a bit ambiguous. It might be better to use "addTask" instead.
TPH777
left a comment
There was a problem hiding this comment.
Coding standards and code quality is not strictly followed, improvements can be made
| private static int last_index = 0; | ||
|
|
||
| public static void echo(String msg) { | ||
| System.out.println("____________________________________________________________\n"); |
There was a problem hiding this comment.
Abstracting the printing of divider to a function will improve readability
|
|
||
| public class Poirot { | ||
| private static Task[] list_actions = new Task[100]; | ||
| private static int last_index = 0; |
There was a problem hiding this comment.
size may be a better name than last_index
| import java.util.Scanner; | ||
|
|
||
| public class Poirot { | ||
| private static Task[] list_actions = new Task[100]; |
There was a problem hiding this comment.
Use camelCase for variables, E.g. listActions, but a better name will be tasks
| } 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()); |
There was a problem hiding this comment.
Abstract this to a function and give variable names for list_actions[i].getStatusIcon() and list_actions[i].getDescription to improve code readability
| System.out.println("____________________________________________________________\n"); | ||
| break; | ||
| case "unmark": | ||
| int y = Integer.parseInt(list_input[1]) - 1; |
There was a problem hiding this comment.
Set a variable for list_input[1] as it is unclear what is that
| System.out.println("____________________________________________________________\n"); | ||
| break; | ||
| case "unmark": | ||
| int y = Integer.parseInt(list_input[1]) - 1; |
Merge branch-Level-5 with master branch
Mahesh1772
left a comment
There was a problem hiding this comment.
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
| } | ||
| @Override | ||
| public String toFileString() { | ||
| return "D | " + (isDone ? "1" : "0") + " | " + description + " | " + by; |
There was a problem hiding this comment.
Consider adding the description in the parent classes toFIleString() to make full use of the inheritance principles
|
|
||
| @Override | ||
| public String toString() { | ||
| return "[E][" + getStatusIcon() + "] " + description + " (from: " + from + " to: " + to + ")"; |
There was a problem hiding this comment.
Consider adding the description in the parent classes toFIleString() to make full use of the inheritance principles
| 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; |
There was a problem hiding this comment.
Consider naming the variables with more than one word in camelCase
| @@ -0,0 +1,204 @@ | |||
| import java.io.*; | |||
There was a problem hiding this comment.
Try not to use the * to import everything. Instead explicitly import what is needed.
| public abstract String toString(); | ||
| public abstract String toFileString(); |
There was a problem hiding this comment.
Consider making then non abstract methods, as they can be easily utilized by sub-classes. As such, Task could not be a abstract class.
| 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(); |
There was a problem hiding this comment.
Consider saving the string formatted with the current isDone in a separate method inside Task class to reduce duplicate lines of code
|
|
||
| boolean working = true; | ||
| Scanner scan = new Scanner(System.in); | ||
| while (working) { |
There was a problem hiding this comment.
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
Branch level 9
No description provided.