Skip to content

Sparsh/IncyBot iP#194

Open
IncyBot wants to merge 22 commits into
nus-cs2113-AY2324S2:masterfrom
IncyBot:master
Open

Sparsh/IncyBot iP#194
IncyBot wants to merge 22 commits into
nus-cs2113-AY2324S2:masterfrom
IncyBot:master

Conversation

@IncyBot
Copy link
Copy Markdown

@IncyBot IncyBot commented Feb 9, 2024

No description provided.

Added Personality and the ability to store whatever text entered by the user and display them back to the user when requested.
Added the ability to mark tasks as done and the ability to change the status back to not done.
Copy link
Copy Markdown

@Jai2501 Jai2501 left a 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!

Comment thread src/main/java/Incy.java Outdated
Comment on lines +5 to +12
Scanner scanner = new Scanner(System.in);
String input;
Task[] tasks = new Task[100];
int taskCount = 0;
String logo = " ____ _ _ ___ _ _ \n"
+ "(_ _)( \\( )/ __)( \\/ )\n"
+ " _)(_ ) (( (__ \\ / \n"
+ "(____)(_)\\_)\\___) (__) \n";
Copy link
Copy Markdown

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

Comment thread 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];
Copy link
Copy Markdown

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.

Reference: https://nus-cs2113-ay2324s2.github.io/website/se-book-adapted/chapters/codeQuality.html#avoid-magic-numbers

Comment thread src/main/java/Incy.java
Comment on lines +20 to +76
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();
}
Copy link
Copy Markdown

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:

  1. https://nus-cs2113-ay2324s2.github.io/website/se-book-adapted/chapters/codeQuality.html#avoid-deep-nesting
  2. https://nus-cs2113-ay2324s2.github.io/website/se-book-adapted/chapters/codeQuality.html#avoid-long-methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants