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

[javienneyeo] ip #215

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

Conversation

javienneyeo
Copy link

No description provided.

Copy link

@wcwy wcwy left a comment

Choose a reason for hiding this comment

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

Good job in splitting the classes with similar nature into the same packages. The classes created by you now are also on point too. So far, I don't see any issue w.r.t. coding standards. Keep the good work going! Below are some comments on some minor coding quality issues and some suggestions.

@@ -0,0 +1,6 @@
package duke.exceptions;

public class UnknownCommandException extends Exception {
Copy link

Choose a reason for hiding this comment

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

Instead of having the content of the exception empty, you can consider doing some interesting and useful stuff within the exception, such as declaring a function to print the error message.

private static void createEvent(Task[] tasks, String task) {
String[] words = task.split("/from");
String description = words[0];
String[] words2 = words[1].split("/to");
Copy link

Choose a reason for hiding this comment

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

Instead of calling it words and words2, you might want to think of other more related or intuitive namings for them


private static void editList() throws UnknownCommandException, EmptyDescriptionException, TaskToMarkDoesNotExistException {
String[] splitText = getInput();
Task[] tasks = new Task[100];
Copy link

Choose a reason for hiding this comment

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

Your current code structure only accepts a maximum of 100 tasks for now. Moving on, you might want to make this more flexible by using ArrayList.

Comment on lines 117 to 119
default:
throw new UnknownCommandException();
}
Copy link

Choose a reason for hiding this comment

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

Good use of default branch.

Comment on lines 10 to 14
if (typeOfTask.equals("marked") || typeOfTask.equals("unmarked")) {
System.out.println("OOPS!! Task to be " + typeOfTask + " was not specified!");
} else {
System.out.println("OOPS!! The description of " + typeOfTask + " cannot be empty!");
}
Copy link

Choose a reason for hiding this comment

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

Instead of checking whether it is marked or unmarked and proceed to print a different error message for it, you might want to just create another exception separately for the mark and unmark feature.


private static String[] getInput() {
Scanner input = new Scanner(System.in);
String text = input.nextLine(); // input the whole sentence into text
Copy link

Choose a reason for hiding this comment

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

Generally, we would want to capitalise the first letter in our comment.

System.out.println("Here are the tasks in your list:");
for (int i = 0; i < Task.numberOfTasks; i += 1) {
System.out.print(i + 1 + ". ");
tasks[i].printTask();
Copy link

Choose a reason for hiding this comment

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

This is a good usage of polymorphism. When you are implementing the features in future levels, you might want to think about using similar techniques for other appropriate features too.

@@ -1,10 +1,138 @@
import duke.tasks.Task;
Copy link

Choose a reason for hiding this comment

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

I noticed that your Duke.java file is outside the duke folder. You might want to move it into that folder such that all your code is under the folder. You could use the move class feature under refactor to achieve it.


@Override
public void printTask() {
System.out.println("[D][" + getStatusIcon() + "] " + description + "(by:" + end + ")");
Copy link

Choose a reason for hiding this comment

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

Arguably, strings like [D] can be seen as a magic strings. You might want to consider extracting strings like this into a named constants. Sometimes, you could also use enums to achieve similar effect. There could be other magic strings/numbers/literals in your other code too that you might want to look out for them.

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.

2 participants