You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the code further.
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most one example is given i.e., there can be other areas/places to improve.
publicstaticvoidmain(String[] args) {
sendWelcomeMessage();
List<Task> tasks = newArrayList<>();
readDataFromFile(tasks);
System.out.println(LINE_BREAK);
StringuserInput;
do {
userInput = SCANNER.nextLine();
System.out.println(LINE_BREAK);
// Solution below adapted from: https://stackoverflow// .com/questions/5067942/what-is-the-best-way-to-extract-the-first-word-from-a-string-in-javaString[] array = userInput.split(SPACE_SEPARATOR, 2);
Stringaction = array[0];
switch (action) {
caseLIST_STRING:
listAllTasks(tasks);
break;
caseDONE_STRING:
try {
markTaskAsDone(tasks, array[1]);
} catch (ArrayIndexOutOfBoundsExceptione) {
System.out.println("Let me know which task you would like to mark as done?");
}
break;
caseTODO_STRING:
try {
addToDoTask(tasks, array[1]);
} catch (ArrayIndexOutOfBoundsExceptione) {
System.out.println("Sure, let me know what ToDo task you would like to add!");
}
break;
caseDEADLINE_STRING:
try {
addDeadlineTask(tasks, array[1]);
} catch (ArrayIndexOutOfBoundsExceptione) {
System.out.println("Sure, let me know what Deadline task you would like to add!");
} catch (ChattyChatBotExceptione) {
System.out.println("Please specify the deadline of your task");
}
break;
caseEVENT_STRING:
try {
addEventTask(tasks, array[1]);
} catch (ArrayIndexOutOfBoundsExceptione) {
System.out.println("Sure, let me know what Event task you would like to add!");
} catch (ChattyChatBotExceptione) {
System.out.println("Please specify the time of your event");
}
break;
caseDELETE_STRING:
try {
deleteTask(tasks, array[1]);
} catch (ArrayIndexOutOfBoundsExceptione) {
System.out.println("Let me know which task you would like to delete?");
}
break;
caseBYE_STRING:
saveDataToFile(tasks);
sendByeMessage();
break;
default:
sendDefaultResponse();
}
System.out.println(LINE_BREAK);
} while (!userInput.equals(BYE_STRING));
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods.
The text was updated successfully, but these errors were encountered:
We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the code further.
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most one example is given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
No easy-to-detect issues 👍
Aspect: Brace Style
No easy-to-detect issues 👍
Aspect: Package Name Style
No easy-to-detect issues 👍
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
No easy-to-detect issues 👍
Aspect: Method Length
Example from
src/main/java/chatty/ChattyChatBot.java
line27
:Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods.
The text was updated successfully, but these errors were encountered: