-
Notifications
You must be signed in to change notification settings - Fork 78
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
base: master
Are you sure you want to change the base?
[bljhty] iP #65
Conversation
renamed chatbot from duke to Dom, added the various lines
imporved on level-2 code completed level-3
There was a problem hiding this 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
src/main/java/Duke.java
Outdated
System.out.println("Hello from\n" + logo); | ||
String greetings = "____________________________________________________________" + "\n" + |
There was a problem hiding this comment.
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?
src/main/java/Duke.java
Outdated
* This method prints the list of tasks. | ||
*/ | ||
private static void listTasks(ArrayList<Task> tasks) { | ||
if (tasks.isEmpty()) { |
There was a problem hiding this comment.
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.
src/main/java/Duke.java
Outdated
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.
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.
src/main/java/Duke.java
Outdated
String command = givenTask.nextLine(); | ||
System.out.println("____________________________________________________________"); | ||
|
||
if (command.equalsIgnoreCase("bye")) { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
src/main/java/Duke.java
Outdated
System.out.println(goodbye); | ||
} | ||
|
||
public static void getHelp() { |
There was a problem hiding this comment.
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.
src/main/java/Duke.java
Outdated
} 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.
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!
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.