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
@TyrusLye 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 iP code further.
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
publicstaticvoidmain(String[] args) {
Scannerscanner = newScanner(System.in);
ArrayList<Task> tasks = newArrayList<>(100);
loadTasksFromFile(tasks);
Stringlogo = "██╗░░░██╗██████╗░██████╗░░█████╗░██╗\n"
+ "██║░░░██║██╔══██╗██╔══██╗██╔══██╗██║\n"
+ "██║░░░██║██████╔╝██████╦╝██║░░██║██║\n"
+ "██║░░░██║██╔══██╗██╔══██╗██║░░██║██║\n"
+ "╚██████╔╝██║░░██║██████╦╝╚█████╔╝██║\n"
+ "░╚═════╝░╚═╝░░╚═╝╚═════╝░░╚════╝░╚═╝\n";
System.out.println("Hello from\n" + logo);
System.out.println("What can I do for you?");
System.out.println("____________________________________________________________");
while (true) {
Stringcommand = scanner.nextLine();
System.out.println("____________________________________________________________");
try{
if (command.equalsIgnoreCase("bye")) {
System.out.println("Bye. Hope to see you again soon!");
break;
} elseif (command.equalsIgnoreCase("list")) {
System.out.println("Here are the tasks in your list:");
for (inti = 0; i < tasks.size(); i++) {
System.out.println((i + 1) + ". " + tasks.get(i));
}
} elseif (command.startsWith("todo")) {
Stringdescription = command.substring(5).trim();
if (description.isEmpty()) {
thrownewDukeException("The description of a todo cannot be empty.");
}
tasks.add(newTodo(description));
System.out.println("Got it. I've added this task:\n " + tasks.get(tasks.size() - 1));
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
} elseif (command.startsWith("deadline")) {
// Parse the date and time in the format d/M/yyyy HHmmString[] parts = command.split(" /by ");
if (parts.length < 2) {
thrownewDukeException("Deadline command must include a date.");
}
Stringdescription = parts[0].substring(9).trim();
LocalDateTimedateTime = LocalDateTime.parse(parts[1], DateTimeFormatter.ofPattern("d/M/yyyy HHmm"));
tasks.add(newDeadline(description, dateTime));
System.out.println("Got it. I've added this task:\n " + tasks.get(tasks.size() - 1));
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
} elseif (command.startsWith("event")) {
Stringdescription = command.substring(6, command.indexOf("/from")).trim();
Stringfrom = command.substring(command.indexOf("/from") + 6, command.indexOf("/to")).trim();
Stringto = command.substring(command.indexOf("/to") + 4).trim();
tasks.add(newEvent(description, from, to));
System.out.println("Got it. I've added this task:\n " + tasks.get(tasks.size() - 1));
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
} elseif (command.startsWith("mark")) {
intindex = Integer.parseInt(command.split(" ")[1]) - 1;
if (index >= 0 && index < tasks.size()) {
tasks.get(index).markDone();
System.out.println("Nice! I've marked this task as done:\n " + tasks.get(index));
} else {
System.out.println("Invalid task index.");
}
} elseif (command.startsWith("unmark")) {
intindex = Integer.parseInt(command.split(" ")[1]) - 1;
if (index >= 0 && index < tasks.size()) {
tasks.get(index).markNotDone();
System.out.println("OK, I've marked this task as not done yet:\n " + tasks.get(index));
} else {
System.out.println("Invalid task index.");
}
} elseif (command.startsWith("delete")) {
intindex = Integer.parseInt(command.split(" ")[1]) - 1;
if (index >= 0 && index < tasks.size()) {
TaskremovedTask = tasks.remove(index);
System.out.println("Noted. I've removed this task:\n " + removedTask);
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
} else {
System.out.println("Invalid task index.");
}
} else {
thrownewDukeException("I'm sorry, but I don't know what that means :-(");
}
saveTasksToFile(tasks);
}
catch (DukeExceptione) {
System.out.println("☹ OOPS!!! " + e.getMessage());
}
System.out.println("____________________________________________________________");
}
scanner.close();
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
ℹ️ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact [email protected] if you want to follow up on this post.
The text was updated successfully, but these errors were encountered:
@TyrusLye 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 iP code further.
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
No easy-to-detect issues 👍
Aspect: Naming boolean variables/methods
No easy-to-detect issues 👍
Aspect: Brace Style
Example from
src/main/java/Duke.java
lines92-93
:Suggestion: As specified by the coding standard, use egyptian style braces.
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/Duke.java
lines10-102
:Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
Aspect: Class size
No easy-to-detect issues 👍
Aspect: Header Comments
No easy-to-detect issues 👍
Aspect: Recent Git Commit Message
possible problems in commit
5310a44
:possible problems in commit
f0cc53b
:possible problems in commit
c8920e9
:Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).
Aspect: Binary files in repo
No easy-to-detect issues 👍
ℹ️ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact
[email protected]
if you want to follow up on this post.The text was updated successfully, but these errors were encountered: