-
Notifications
You must be signed in to change notification settings - Fork 187
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
Sparsh/IncyBot iP #194
base: master
Are you sure you want to change the base?
Sparsh/IncyBot iP #194
Conversation
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid the use of Magic Numbers. Instead declare a constant with the value you deem is right, and use that constant.
src/main/java/Incy.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.