[Ong Jun Lin Jeremiah] iP#212
Conversation
| @@ -1,10 +1,73 @@ | |||
| public class Duke { | |||
| import java.util.Scanner; | |||
| import java.util.*; | |||
There was a problem hiding this comment.
Perhaps you could list the imported classes explicitly
| public class | ||
| Duke { |
There was a problem hiding this comment.
| public class | |
| Duke { | |
| public class Duke { |
| String logo = " ____ _ \n" | ||
| + "| _ \\ _ _| | _____ \n" | ||
| + "| | | | | | | |/ / _ \\\n" | ||
| + "| |_| | |_| | < __/\n" | ||
| + "|____/ \\__,_|_|\\_\\___|\n"; | ||
| System.out.println("Hello from\n" + logo); | ||
|
|
||
| String greeting = ("____________________________________________________________\n" | ||
| + "Hello! I'm Duke\n" + "What can I do for you?\n" | ||
| + "____________________________________________________________\n" | ||
| ); | ||
|
|
||
| String goodBye = ("____________________________________________________________\n" | ||
| + "Bye. Hope to see you again soon!\n" | ||
| + "____________________________________________________________\n"); |
There was a problem hiding this comment.
Perhaps you can change your constant names to be all uppercase using underscore to separate words
| System.out.println("OK, I've marked this task as not done yet:\n" + " " | ||
| + toDoList.get(itemNumber).getStatusIcon() + toDoList.get(itemNumber).getDescription()); |
There was a problem hiding this comment.
I think you did a good job indenting wrapped lines.
| String greeting = ("____________________________________________________________\n" | ||
| + "Hello! I'm Duke\n" + "What can I do for you?\n" | ||
| + "____________________________________________________________\n" | ||
| ); | ||
|
|
||
| String goodBye = ("____________________________________________________________\n" | ||
| + "Bye. Hope to see you again soon!\n" | ||
| + "____________________________________________________________\n"); |
There was a problem hiding this comment.
You may want to refactor the greeting and goodbye into another function instead of putting it all in main(). For example a void printGreeting() function that just prints the greeting
| public class Task { | ||
| protected String description; | ||
| protected boolean isDone; | ||
| protected int taskNumber; |
There was a problem hiding this comment.
There are no methods that uses taskNumber?
| String logo = " ____ _ \n" | ||
| + "| _ \\ _ _| | _____ \n" | ||
| + "| | | | | | | |/ / _ \\\n" | ||
| + "| |_| | |_| | < __/\n" | ||
| + "|____/ \\__,_|_|\\_\\___|\n"; | ||
| System.out.println("Hello from\n" + logo); |
There was a problem hiding this comment.
Can be refactored into print logo function, or you can combine it with the print greeting function
| ArrayList<Task> toDoList = new ArrayList<Task>(100); | ||
|
|
||
| while (!userInput.equals("bye")) { | ||
| if (!containsNumbers(userInput)) { |
There was a problem hiding this comment.
You probably don't need this if clause. Instead, you can see if the input string contains "list", "mark", or "unmark", and create 3 separate switch cases for them. Even better, you can refactor this entire if else block into a function that parses the user input.
| System.out.print(item.getStatusIcon()); | ||
| System.out.println(item.getDescription()); | ||
| } | ||
| System.out.println("____________________________________________________________\n"); |
There was a problem hiding this comment.
You can declare a constant for the row of underscores, or you can just create a function printLine to print the row of underscores. Also, you may want to use System.lineSeparator() instead of '\n' as recommended by the module.
| System.out.print((toDoList.indexOf(item) + 1) + "."); | ||
| System.out.print(item.getStatusIcon()); | ||
| System.out.println(item.getDescription()); |
There was a problem hiding this comment.
Can be refactored into a separate function printTask(), since all tasks have the same format to be printed. In addition, depending on the situation, you may want to create a new function for each System.out.print() call, if you print the same thing multiple time.
| public class | ||
| Duke { |
There was a problem hiding this comment.
Please bring Duke { in line 5 to the same line as public class (line 4)
| public class | |
| Duke { | |
| public class Duke { |
|
|
||
| public class | ||
| Duke { | ||
| public static void main(String[] args) { |
There was a problem hiding this comment.
Your main method is far too long, the recommendation according to the textbook is 30 LOC. Please try to modularize your main method.
No description provided.