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