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
@Gavzzz 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) throwsDukeException, IOException, IllegalCommandException {
Stringlogo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
System.out.println("___________________________________");
System.out.println("Hello! I'm Duke\n What can I do for you?");
System.out.println("____________________________________");
Stringinput = sc.nextLine();
Filefile = newFile("database/duke.txt");
if (file.createNewFile()) {
System.out.println("File has been created: " + file.getName());
} else {
System.out.println("File already exists.");
Scannerreader = newScanner(file);
while (reader.hasNext()) {
reader.useDelimiter(" \\| ");
Constantsconstant = Constants.valueOf(reader.next().toUpperCase());
Tasktask;
switch (constant) {
caseTODO:
StringtdDescription = reader.next();
Todotodo = newTodo(tdDescription);
collection.add(todo);
break;
caseDEADLINE:
StringdlDescription = reader.next();
Deadlinedeadline = newDeadline(dlDescription);
collection.add(deadline);
break;
caseEVENT:
StringevDescription = reader.next();
Eventevent = newEvent(evDescription);
collection.add(event);
break;
default:
thrownewIllegalCommandException("Illegal command given");
}
}
}
while (!input.equals("bye")) {
if (input.equals("list")) {
System.out.println("___________________________________");
for (inti = 0; i < collection.size(); i++) {
System.out.println( (i+1) + "."
+ collection.get(i).toString());
}
System.out.println("___________________________________");
input = sc.nextLine();
}
if (input.startsWith("mark")) {
intnumber = Integer.parseInt(input.substring(5));
collection.get(number-1).mark();
System.out.println("___________________________________");
System.out.println("Nice! I've marked this task done: " + "\n"
+ "[" + collection.get(number-1).getStatusIcon() + "] " +
collection.get(number-1).description);
System.out.println("___________________________________");
input = sc.nextLine();
}
if (input.equals("unmark")) {
intnumber = Integer.parseInt(input.substring(7));
collection.get(number-1).unmark();
System.out.println("___________________________________");
System.out.println("OK, I've marked this task as not done yet: " + "\n"
+ "[" + collection.get(number-1).getStatusIcon() + "] " +
collection.get(number-1).description);
System.out.println("___________________________________");
input = sc.nextLine();
}
if (input.startsWith("deadline")) {
try {
if (isNotValid(input))
thrownewDukeException("☹ OOPS!!! The description of a deadline cannot be empty.");
Deadlinedeadline = newDeadline(input);
collection.add(deadline);
System.out.println("___________________________________");
System.out.println("Got it. I've added this task:" + "\n"
+ " " + deadline.toString() + "\n"
+ "Now you have " + collection.size() + " tasks in the list.");
System.out.println("___________________________________");
} catch(DukeExceptione) {
System.out.println(e.getMessage());
} finally {
input = sc.nextLine();
}
}
if (input.startsWith("todo")) {
try {
if (isNotValid(input))
thrownewDukeException("☹ OOPS!!! The description of a todo cannot be empty.");
Todotodo = newTodo(input);
collection.add(todo);
System.out.println("___________________________________");
System.out.println("Got it. I've added this task:" + "\n"
+ " " + todo.toString() + "\n"
+ "Now you have " + collection.size() + " tasks in the list.");
System.out.println("___________________________________");
} catch(DukeExceptione) {
System.out.println(e.getMessage());
} finally {
input = sc.nextLine();
}
}
if (input.startsWith("event")) {
try {
if (isNotValid((input)))
thrownewDukeException("☹ OOPS!!! The description of a event cannot be empty.");
Eventevent = newEvent(input);
collection.add(event);
System.out.println("___________________________________");
System.out.println("Got it. I've added this task:" + "\n"
+ " " + event.toString() + "\n"
+ "Now you have " + collection.size() + " tasks in the list.");
System.out.println("___________________________________");
} catch(DukeExceptione) {
System.out.println(e.getMessage());
} finally {
input = sc.nextLine();
}
}
if (input.startsWith("delete")) {
intnumber = Integer.parseInt(input.substring(7));
Tasktemp = collection.get(number-1);
collection.remove(number-1);
System.out.println("___________________________________");
System.out.println("Noted. I've removed this task:" + "\n"
+ " " + temp.toString() + "\n"
+ "Now you have " + collection.size() + " tasks in the list.");
System.out.println("___________________________________");
input = sc.nextLine();
}
else {
try {
thrownewDukeException(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-(.");
} catch (DukeExceptione) {
System.out.println(e.getMessage());
} finally {
input = sc.nextLine();
}
}
}
FileWriterfileWriter = newFileWriter(file);
for (Tasktask : collection) {
fileWriter.write(task.fileFormat() + System.lineSeparator());
}
fileWriter.close();
System.out.println("___________________________________");
System.out.println("Bye. Hope to see you again soon!");
System.out.println("___________________________________");
}
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:
@Gavzzz 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
lines178-179
:else {
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
lines24-199
: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 (Subject Only)
possible problems in commit
495d75f
:edited Level 2
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: