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/Duke.java lines 11-73:
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Hello! I'm Duke\n"+ "What can I do for you?");
ArrayList<Task> items = new ArrayList<>();
while (true) {
String input = sc.nextLine();
try {
errorHandling(input);
if (input.equals("bye")) {
bye();
break;
} else if (input.contains("done")) {
System.out.println("Nice! I've marked this task as done: ");
int taskNum = Integer.parseInt(input.substring(5));
String name = items.get(taskNum - 1).getDescription();
Task type = items.get(taskNum - 1);
items.remove(taskNum - 1);
if (type instanceof Todo) {
Todo markDone = new Todo(name, true);
items.add(taskNum - 1, markDone);
System.out.println(markDone);
} else if (type instanceof Deadline) {
Deadline markDone = new Deadline(name, true);
items.add(taskNum - 1, markDone);
System.out.println(markDone);
} else {
Event markDone = new Event(name, true);
items.add(taskNum - 1, markDone);
System.out.println(markDone);
}
} else if (input.equals("list")) {
int n = 1;
System.out.println("Here are the tasks in your list:");
for (Task item : items) {
System.out.println(n + ". " + item);
n++;
}
} else if (input.length() >= 8 && input.substring(0,8).equals("deadline")) {
items.add(new Deadline(input.substring(8)));
} else if (input.length() >= 4 && input.substring(0,4).equals("todo")) {
items.add(new Todo(input.substring(4)));
} else if (input.length() >= 5 && input.substring(0,5).equals("event")) {
items.add(new Event(input.substring(5)));
} else if (input.length() >= 6 && input.substring(0,6).equals("delete")) {
int taskToDelete = Integer.parseInt(input.substring(7));
Task toRemove = items.get(taskToDelete - 1);
items.remove(taskToDelete - 1);
System.out.println("Noted. I've removed this task:\n "
+ toRemove + "\nNow you have " + items.size() + " tasks in the list.");
} else {
items.add(new Task(input));
}
} catch (Exception e) {
System.out.println(e);
}
}
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
ℹ️ The bot account @cs2103-bot used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact cs2103@comp.nus.edu.sg if you want to follow up on this post.
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/Duke.javalines11-73:Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
ℹ️ The bot account @cs2103-bot used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact
cs2103@comp.nus.edu.sgif you want to follow up on this post.