[bljhty] iP#65
Conversation
renamed chatbot from duke to Dom, added the various lines
imporved on level-2 code completed level-3
SebasFok
left a comment
There was a problem hiding this comment.
Looks good! Very clear comments used to allow readers to understand your train of thought
| + " | |_| | (_) | | | | | |\n" | ||
| + " |____/ \\___/|_| |_| |_|\n"; | ||
| System.out.println("Hello from\n" + logo); | ||
| String greetings = "____________________________________________________________" + "\n" + |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
I like how you considered the case when the list is empty so that the user knows that his input was read.
| 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); |
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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.
irving11119
left a comment
There was a problem hiding this comment.
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 No newline at end of file | |||
There was a problem hiding this comment.
Perhaps you could add this file to your .gitignore.
| System.out.println(goodbye); | ||
| } | ||
|
|
||
| public static void getHelp() { |
There was a problem hiding this comment.
Perhaps you could consider making this a named constant instead to avoid having magic strings.
| } 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"); | ||
| } |
There was a problem hiding this comment.
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!
change from else if statements to case statements
* branch-level-6: Level-6 increment done
* branch-level-7: added level-7 increments # Conflicts: # src/main/java/Duke.java
Level-9 increment done
* 'master' of https://github.com/bljhty/ip: Level-9 increment done
added more javaDoc
added changes to userguide
No description provided.