Skip to content

[sweetFish8] iP#189

Open
sweetFish8 wants to merge 51 commits into
nus-cs2113-AY2425S2:masterfrom
sweetFish8:master
Open

[sweetFish8] iP#189
sweetFish8 wants to merge 51 commits into
nus-cs2113-AY2425S2:masterfrom
sweetFish8:master

Conversation

@sweetFish8
Copy link
Copy Markdown

No description provided.

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

@Override
public String toString() {
return "[E]" + super.toString() + " (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.

Perhaps use a variable to store [E]/[T]/[D] literals?

Comment thread src/main/java/Sparkle.java Outdated
Comment thread src/main/java/Sparkle.java Outdated
}

private static void printTaskList(Task[] tasks, int taskCount) {
System.out.println(" ____________________________________________________________");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe assign this partition to a final string variable to use multiple times?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i will do that! thx

Comment thread src/main/java/Sparkle.java Outdated
Comment thread src/main/java/Sparkle.java Outdated
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

String logo =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Interesting logo! But seems a bit messy.

Copy link
Copy Markdown

@tongkiankiat tongkiankiat left a comment

Choose a reason for hiding this comment

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

The code looks neat and well done, with good use of methods to handle different cases. Good job!

Comment thread src/main/java/Sparkle.java Outdated
if (taskNumber >= 0 && taskNumber < taskCount) {
if (isMark) {
tasks[taskNumber].markAsDone();
System.out.println(" ____________________________________________________________");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could store this string in a variable to reduce character space as its being reused constantly

Comment thread src/main/java/Sparkle.java Outdated
+ " _____________________________"
+ "_______________________________\n"
+ "\n"
+ logo);
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 practice storing the large text display in a variable and not type it again to prevent excessive lines of code

Comment thread src/main/java/Event.java Outdated
this.to = to;
}

@Override
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 practice including the @ Override tag when overriding a method.

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

@Override
public String toString() {
return "[T]" + super.toString();
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 the [T], [D], [E] strings are appearing multiple times, maybe could store them in a variable?

Copy link
Copy Markdown

@thomasjlalba thomasjlalba 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 and like the personalisation of your iP. Just some small suggestions to improve code quality

Comment thread src/main/java/sparkle/core/Sparkle.java Outdated
String details = commandParts.length > 1 ? commandParts[1].trim() : "";

switch (command) {
case "bye":
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe you can avoid magic literals.

Comment thread src/main/java/sparkle/core/Sparkle.java Outdated
Comment on lines +107 to +123
if (details.isEmpty())
throw new SparkleException(
SparkleException.ErrorType.EMPTY_TASK_DESCRIPTION, "Event");
String[] eventParts = details.split(" /from ", 2);
if (eventParts.length < 2 || !eventParts[1].contains(" /to ")) {
throw new SparkleException(
SparkleException.ErrorType.INVALID_FORMAT, "Event requires /from and /to time.");
}
String[] timeParts = eventParts[1].split(" /to ", 2);
tasks[taskCount] =
new Event(eventParts[0].trim(), timeParts[0].trim(), timeParts[1].trim());
printAddedTask(tasks[taskCount++], taskCount);
break;

default:
throw new SparkleException(SparkleException.ErrorType.UNKNOWN_COMMAND, command);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe you can look into abstracting the cases into their own methods to make it less cluttered

Comment thread src/main/java/sparkle/core/Sparkle.java Outdated
printTaskList(tasks, taskCount);
break;

case "mark":
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe you can explicitly state // Fallthrough to indicate it is intentional as per coding standards

Comment thread src/main/java/sparkle/core/Sparkle.java Outdated
if (details.isEmpty())
throw new SparkleException(SparkleException.ErrorType.EMPTY_TASK_DESCRIPTION, "Todo");
tasks[taskCount] = new Todo(details);
printAddedTask(tasks[taskCount++], taskCount);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe you can look to avoid complicated expressions in your code, for example separating the taskCount++ to another line to improve readability.

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