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

[Ho Wei Yi Stanley] iP #99

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

Conversation

beaniestanley
Copy link

No description provided.

}

public String getStatusIcon() {
return (isDone ? "\u2713" : " "); //return tick symbol if task is done
Copy link

Choose a reason for hiding this comment

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

Perhaps this unicode can be replaced with a more expressive constant instead, so that the comment can be removed

Copy link
Author

Choose a reason for hiding this comment

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

Got it! Fixed :)

System.out.println("\t__________________________________________\n");

ArrayList<Task> tasks = new ArrayList<Task>();
int taskCount = 0;
Copy link

Choose a reason for hiding this comment

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

Instead of using the taskCount variable, is it possible to use tasks.length instead, so there is one less variable to manage?

Copy link
Author

Choose a reason for hiding this comment

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

Good idea. Fixed it already!

Copy link

@tehtea tehtea left a comment

Choose a reason for hiding this comment

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

Generally, no coding standard violations. Good job!

this.by = by;
}

@Override
Copy link

Choose a reason for hiding this comment

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

Neat use of method overriding too for each entity

// sets a task as done
System.out.println("\tGreat job! I've marked this task as done: ");
Task task = tasks.get(taskIndex - 1);
task.markAsDone();
Copy link

Choose a reason for hiding this comment

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

All method names are in camelCase too

Copy link

@AlexanderTanJunAn AlexanderTanJunAn left a comment

Choose a reason for hiding this comment

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

Great job overall!

System.out.println("\t__________________________________________\n");

ArrayList<Task> tasks = new ArrayList<>();
boolean runLoop = true;

Choose a reason for hiding this comment

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

Naming of boolean variable is very readable. Very good!

this.at= at;
}

@Override

Choose a reason for hiding this comment

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

Good use of method overriding, allows Event class to inherit from parent Task class. Very good!

// if list is empty
System.out.println("\tYour list is empty!");
}
else {

Choose a reason for hiding this comment

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

If else statements should follow proper code standards! Small issue as the other statements follow them.

System.out.println("\tWhat can I help you with?");
System.out.println("\t__________________________________________\n");

ArrayList<Task> tasks = new ArrayList<>();

Choose a reason for hiding this comment

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

Collection of tasks is in plural form! Good!

Copy link

@lowwilliam lowwilliam left a comment

Choose a reason for hiding this comment

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

Overall good code quality! Clean and easy to understand and track!

while (runLoop) {

String userInput = sc.nextLine().trim();

Choose a reason for hiding this comment

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

No need to leave space between these


public Task(String description) {
this.description = description;
this.isDone = false;

Choose a reason for hiding this comment

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

good use of naming and Class with super


@Override
public String toString() {
return "[D]" + super.toString() + "(by: " + this.by + ")";

Choose a reason for hiding this comment

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

This is a very clear structure of code, I will also apply this in mine

System.out.println("\t__________________________________________\n");
} else {
// adds a task to the list
System.out.println("\t------------------------------------------");

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 a different form of lines, one:----- and one––––––––, it performs different meanings and let users easily understood.


String userInput = sc.nextLine().trim();

if (userInput.equals("bye")) {

Choose a reason for hiding this comment

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

Could modify so that it is not case-sensitive

runLoop = false;
} else if (userInput.equals("list")) {
System.out.println("\t------------------------------------------");
if (tasks.size() == 0) {

Choose a reason for hiding this comment

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

Good to check if the list is empty before printing out the list!

} else {
// adds a task to the list
System.out.println("\t------------------------------------------");
switch(userInput.split(" ")[0]) {

Choose a reason for hiding this comment

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

could make a method to add task make code neater!

break;
case "event":
// adds event tasks
Task event = new Event(userInput.substring(6, userInput.indexOf("/at")),

Choose a reason for hiding this comment

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

userInput.indexOf("/at")+4 could be confusing

Copy link

@rabhijit rabhijit left a comment

Choose a reason for hiding this comment

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

Good work! I think you follow code naming conventions and coding standards well. I think you could work on simplifying and breaking down complicated expressions and methods; readability is the name of the game here. Additionally, consider code organisation; you could split your code into more classes, as a lot of your program's functionality seems to be happening in just one class.


public Deadline(String description, String by) {
super(description);
this.by = by;

Choose a reason for hiding this comment

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

Consider using a more descriptive variable name that better illustrates what the variable represents.

}

public String getStatusIcon() {
return (isDone ? "X" : " ");

Choose a reason for hiding this comment

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

Though I understand what you're doing here, from a code readability standpoint, it's best to avoid conditionals in favour of a more explicit and clear if-else statement.


public static void exitProgram() {
// exits the program
System.out.println("\t------------------------------------------");

Choose a reason for hiding this comment

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

If you're using this string a lot, perhaps consider storing it as a constant variable that you could re-use elegantly.

}

public static void markTask(String userInput, ArrayList<Task> tasks) throws NumberFormatException,
IndexOutOfBoundsException {

Choose a reason for hiding this comment

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

Good that you followed wrapped-line indentation of 8 spaces!

} else if (userInput.split(" ")[0].equalsIgnoreCase("done")) {
markTask(userInput, tasks);
}
else if (userInput.split(" ")[0].equalsIgnoreCase("delete")) {

Choose a reason for hiding this comment

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

Perhaps you could avoid complicated (and repeated) expressions by breaking it down into multiple lines and storing it as a variable first; I noticed the same issue in a few other classes too, and it would help a reader understand your code better!

System.out.println("\t__________________________________________\n");
}

public static void addTask(String userInput, ArrayList<Task> tasks) throws StringIndexOutOfBoundsException {

Choose a reason for hiding this comment

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

This method is really long; consider breaking it down into smaller methods that would also make it easier for you to debug your own work. Maybe, upon doing so, you could move some of those methods to their relevant class (i.e. Deadline class, Event class, etc) to enhance code organisation

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.

6 participants