Conversation
Jai2501
left a comment
There was a problem hiding this comment.
Hi Sparsh!
Good job on the work done so far!
I have reviewed your code and have left some comments. Please go through them and get back to me for any clarifications.
Thanks!
src/main/java/Incy.java
Outdated
| Scanner scanner = new Scanner(System.in); | ||
| String input; | ||
| Task[] tasks = new Task[100]; | ||
| int taskCount = 0; | ||
| String logo = " ____ _ _ ___ _ _ \n" | ||
| + "(_ _)( \\( )/ __)( \\/ )\n" | ||
| + " _)(_ ) (( (__ \\ / \n" | ||
| + "(____)(_)\\_)\\___) (__) \n"; |
There was a problem hiding this comment.
It is good to specify access modifiers for the variables being declared, like private, public or protected
src/main/java/Incy.java
Outdated
| public static void main(String[] args) { | ||
| Scanner scanner = new Scanner(System.in); | ||
| String input; | ||
| Task[] tasks = new Task[100]; |
There was a problem hiding this comment.
Please avoid the use of Magic Numbers. Instead declare a constant with the value you deem is right, and use that constant.
| while (true) { | ||
| input = scanner.nextLine(); | ||
| if (input.equalsIgnoreCase("bye")) { | ||
| break; | ||
| } else if (input.equalsIgnoreCase("list")) { | ||
| System.out.println("____________________________________________________________"); | ||
| if (taskCount == 0) { | ||
| System.out.println("Blimey, your list is empty, innit?"); | ||
| } else { | ||
| for (int i = 0; i < taskCount; i++) { | ||
| System.out.println((i + 1) + ". " + tasks[i]); | ||
| } | ||
| } | ||
| System.out.println("____________________________________________________________"); | ||
| } else if (input.startsWith("mark ")) { | ||
| int index = Integer.parseInt(input.substring(5)) - 1; | ||
| if (index >= 0 && index < taskCount) { | ||
| tasks[index].markAsDone(); | ||
| System.out.println("____________________________________________________________\n" | ||
| + "Buzzin'! This one's sorted now:\n " | ||
| + tasks[index] | ||
| + "\n____________________________________________________________" | ||
| ); | ||
| } | ||
| } else if (input.startsWith("unmark ")) { | ||
| int index = Integer.parseInt(input.substring(7)) - 1; | ||
| if (index >= 0 && index < taskCount) { | ||
| tasks[index].markAsNotDone(); | ||
| System.out.println("____________________________________________________________\n" | ||
| + "No prob, flipped it back to not done, innit:\n " | ||
| + tasks[index] | ||
| + "\n____________________________________________________________" | ||
| ); | ||
| } | ||
| } else { | ||
| if (taskCount >= tasks.length) { | ||
| System.out.println("____________________________________________________________\n" | ||
| + "Cor blimey! The list is full to the brim. Can't add more, sorry!" | ||
| + "\n____________________________________________________________" | ||
| ); | ||
| } else { | ||
| tasks[taskCount] = new Task(input); | ||
| taskCount++; | ||
| System.out.println("____________________________________________________________\n" | ||
| + "Sorted! Added: " + input | ||
| + "\n____________________________________________________________" | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| System.out.println("____________________________________________________________\n" | ||
| + "Cya later mate!" | ||
| + "\n____________________________________________________________" | ||
| ); | ||
| scanner.close(); | ||
| } |
There was a problem hiding this comment.
This code block is deeply nested, and needs to be worked on.
In general, this method is too long, and it is preferred for methods to be shorter than 30 lines of code.
Please work on abstracting this chunk of code.
References:
Added Level-5 and Handled Exceptions
Added delete Functionality
Added Save Functionality
Taught The Chatbot How to Understand DATES
Added JavaDoc comments to the code.
No description provided.