[Shi Haochen] iP#77
Conversation
| String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; | ||
| String line = "_______________________________________________"; | ||
| String exit = "Bye. Hope to see you again soon!"; | ||
| String listRequirements = "Here are the tasks in your list:"; |
| + "| |_| | |_| | < __/\n" | ||
| + "|____/ \\__,_|_|\\_\\___|\n"; | ||
| System.out.println("Hello from\n" + logo); | ||
| String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; |
There was a problem hiding this comment.
Can use capital letters for constant eg. GREET
| List<Task> todoList = new ArrayList<>(); | ||
| while(true){ | ||
| String input = scanner.nextLine(); | ||
| if(input.equals("bye")){ |
There was a problem hiding this comment.
Remember to add spacing for if else class statements eg. if (something) {
| @@ -1,10 +1,56 @@ | |||
| import java.util.Scanner; | |||
| import java.util.List; | |||
There was a problem hiding this comment.
Good job! names representing packages are in lower case
| @@ -0,0 +1,25 @@ | |||
| public class Task { | |||
There was a problem hiding this comment.
Good job use of PascalCase for classes
vvhuiling
left a comment
There was a problem hiding this comment.
Overall, I found your code easy to read for the most part except main class appears to be a bit packed. Perhaps we can add some blank lines to improve readability. And perhaps encapsulate some of its functionalities if that make sense!
| todoList.get(index-1).markAsDone(); | ||
| System.out.println(line); | ||
| System.out.println(markRequirements); | ||
| System.out.println(" [" + todoList.get(index-1).getStatusIcon() + "] " + todoList.get(index-1).getDescription()); |
There was a problem hiding this comment.
Perhaps spilt the code into 2 lines evenly? first line looks a bit to long for me. I noticed the same issue in several other places too.
| String markFormat = "^mark \\d+$"; | ||
| String unmarkFormat = "^unmark \\d+$"; |
There was a problem hiding this comment.
I have some confusion regarding these strings. Can you provide some clarification on their meaning?
| while(true){ | ||
| String input = scanner.nextLine(); | ||
| if(input.equals("bye")){ | ||
| break; | ||
| }else if(input.equals("list")){ | ||
| System.out.println(line); | ||
| System.out.println(listRequirements); | ||
| for(int i = 0; i < todoList.size(); i++){ | ||
| System.out.println(i+1 + ".[" + todoList.get(i).getStatusIcon() + "] " + todoList.get(i).getDescription()); | ||
| } | ||
| System.out.println(line); | ||
| }else if(input.matches(markFormat)) { | ||
| int index = Integer.parseInt(input.substring(5)); | ||
| todoList.get(index-1).markAsDone(); | ||
| System.out.println(line); | ||
| System.out.println(markRequirements); | ||
| System.out.println(" [" + todoList.get(index-1).getStatusIcon() + "] " + todoList.get(index-1).getDescription()); |
There was a problem hiding this comment.
Perhaps encapsulate some of its functionalities into separate methods so that this while loop can be more concise.
| System.out.println("Hello from\n" + logo); | ||
| String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; | ||
| String line = "_______________________________________________"; | ||
| String exit = "Bye. Hope to see you again soon!"; |
There was a problem hiding this comment.
Since this line is used only once, should it be extracted out and just print it directly when needed?
maanyos
left a comment
There was a problem hiding this comment.
Generally good adherence to coding standards. Some variable names can be improved to be more informative.
Good use of execeptions
| import java.util.List; | ||
| import java.util.ArrayList; | ||
| public class Duke { | ||
| protected final static String line = "_______________________________________________"; |
There was a problem hiding this comment.
follow the correct naming standard for constants
| + "|____/ \\__,_|_|\\_\\___|\n"; | ||
| System.out.println("Hello from\n" + logo); | ||
| String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; | ||
| //String line = "_______________________________________________"; |
Shi Haochen's individual project update.