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

[bljhty] iP #65

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

[bljhty] iP #65

wants to merge 36 commits into from

Conversation

bljhty
Copy link

@bljhty bljhty commented Sep 4, 2023

No description provided.

Copy link

@SebasFok SebasFok left a comment

Choose a reason for hiding this comment

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

Looks good! Very clear comments used to allow readers to understand your train of thought

System.out.println("Hello from\n" + logo);
String greetings = "____________________________________________________________" + "\n" +
Copy link

Choose a reason for hiding this comment

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

Could the line be stored in a string variable so that it could be used more easily elsewhere when formatting?

* This method prints the list of tasks.
*/
private static void listTasks(ArrayList<Task> tasks) {
if (tasks.isEmpty()) {
Copy link

Choose a reason for hiding this comment

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

I like how you considered the case when the list is empty so that the user knows that his input was read.

Comment on lines 50 to 61
Task task = tasks.get(i);
String taskType = task instanceof Todo ? "[T]" : (task instanceof Deadline ? "[D]" : "[E]");
String statusIcon = task.getStatusIcon();
String description = task.getDescription();

if (task instanceof Deadline) {
description += " (by: " + ((Deadline) task).getBy() + ")";
} else if (task instanceof Event) {
description += " (from: " + ((Event) task).getFrom() + " to: " + ((Event) task).getTo() + ")";
}

System.out.println(" " + (i + 1) + "." + taskType + statusIcon + " " + description);
Copy link

Choose a reason for hiding this comment

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

I like how you broke the sentence up into multiple parts such that it is easy to modify it in the future. There is also good use of white spaces to make make the sentence clear to the reader.

String command = givenTask.nextLine();
System.out.println("____________________________________________________________");

if (command.equalsIgnoreCase("bye")) {
Copy link

Choose a reason for hiding this comment

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

Could the if else statements be changed to switch statements for better readability? This could make each branch easier to find and edit in the future.

* Branch-Level-5:
  Level-5 increment + edit code
  edited code

# Conflicts:
#	src/main/java/Duke.java
This reverts commit f50b1a3.
* branch-A-package:
  included packages
Copy link

@irving11119 irving11119 left a comment

Choose a reason for hiding this comment

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

Overall, your code follows the coding standards and your naming conventions are good. However, do try to avoid deep nested as it affects readability of code and try to use constants rather than magic strings and numbers!

@@ -0,0 +1 @@
/Users/bryanlee/Desktop/NUS/NUS Y3S1/CS2113/ip/src/main/java/Duke.java

Choose a reason for hiding this comment

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

Perhaps you could add this file to your .gitignore.

System.out.println(goodbye);
}

public static void getHelp() {

Choose a reason for hiding this comment

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

Perhaps you could consider making this a named constant instead to avoid having magic strings.

Comment on lines 119 to 140
} else if (command.startsWith("mark")) {
if (command.substring(5).isEmpty()) {
System.out.println("Error: Task number cannot be empty\n");
System.out.println("Please enter command in the format: mark <task number>");
}
try {
String[] parts = command.split(" ");
if (parts.length == 2) {
int taskIndex = Integer.parseInt(parts[1]) - 1;
if (taskIndex >= 0 && taskIndex < tasks.size()) {
Task task = tasks.get(taskIndex);
task.markAsDone(true);
System.out.println(
" Nice! I've marked this task as done:\n" + " " + task.getStatusIcon()
+ " " + task.getDescription());
} else {
System.out.println(" Invalid task number.");
}
}
} catch (NumberFormatException e) {
System.out.println("Please enter a valid task number");
}

Choose a reason for hiding this comment

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

Try to avoid deep nesting here and elsewhere in your code. Instead you could try to implement some of the nested logic in another method and call the method!

bljhty and others added 11 commits September 19, 2023 23:19
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.

3 participants