Skip to content

[wongyihao0506] iP #183

Open
wongyihao0506 wants to merge 27 commits intonus-cs2113-AY2425S2:masterfrom
wongyihao0506:master
Open

[wongyihao0506] iP #183
wongyihao0506 wants to merge 27 commits intonus-cs2113-AY2425S2:masterfrom
wongyihao0506:master

Conversation

@wongyihao0506
Copy link
Copy Markdown

No description provided.

System.out.println("OK, I've marked this task as not done yet:\n" + task);
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Decent use of SLAP within your functions
  • Inconsistent naming convention of variables at Line 9
  • Remember to ensure consistency in spacing at Line 31 & 48
  • It is advisable to create more macros for the 'magic' strings in your code

Copy link
Copy Markdown

@Betahaxer Betahaxer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the code looks like a good implementation of the chatbot. With some minor improvements, the readability and naming could be enhanced.

Comment on lines +2 to +3
protected String taskName;
protected boolean isDone;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good naming of attributes eg isDone that explains what the boolean does

Comment on lines +9 to +14
public void markDone() {
isDone = true;
}
public void unmarkDone() {
isDone = false;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good naming of methods as verbs

Comment on lines +15 to +27
if (userInput.equals("bye")) {
System.out.println(Farewell);
break;
} else if (userInput.startsWith("mark ")) {
markList(userInput, true);
} else if (userInput.startsWith("unmark ")) {
markList(userInput, false);
} else if (userInput.equals("list")) {
showList();
} else {
addToList(userInput);
System.out.println("added: " + userInput);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this logic be improved to reduce complexity? eg by using switch case

Comment on lines +8 to +27
String greet = "Hello! I'm Growler \nWhat can I do for you? \n";
String Farewell = "Bye. Hope to see you again soon!";
System.out.println(greet);
String userInput;
Scanner in = new Scanner(System.in);
while (true) {
userInput = in.nextLine();
if (userInput.equals("bye")) {
System.out.println(Farewell);
break;
} else if (userInput.startsWith("mark ")) {
markList(userInput, true);
} else if (userInput.startsWith("unmark ")) {
markList(userInput, false);
} else if (userInput.equals("list")) {
showList();
} else {
addToList(userInput);
System.out.println("added: " + userInput);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the multiple levels of abstraction be avoided? ie can the greetings be abstracted too?

private static ArrayList<Task> list = new ArrayList<>();
public static void main(String[] args) {
String greet = "Hello! I'm Growler \nWhat can I do for you? \n";
String Farewell = "Bye. Hope to see you again soon!";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there can be a better way to name this variable, like write it in camelCase.

int taskNumber = Integer.parseInt(userInput.split(" ")[1]) - 1;
Task task = list.get(taskNumber);

if(mark) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can have another name for the boolean, like isMarked.

Comment on lines +35 to +40
private static void showList(){
System.out.println("Here are the tasks in your list:");
for (int i = 0; i < list.size(); i++){
System.out.println((i+1) + "." + list.get(i));
}
}
Copy link
Copy Markdown

@paklongchiu paklongchiu Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job utilising loop for displaying the list with correct index and wrapping the statement by curly brackets despite there is only one statement.

Comment on lines +41 to +44
private static void addTask(String description){
list.add(new Task(description));
}
private static void markList(String userInput, boolean mark){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of the methods are clear and concise, well done.

Copy link
Copy Markdown

@Hackin7 Hackin7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do more SLAP and abstraction, generally methods are quite long (too long, exceeding 30 LoC)

System.out.println(greet);
String userInput;
Scanner in = new Scanner(System.in);
while (true) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very bad case of arrow head code. I suggest doing more abstraction/ SLAP

}
in.close();
}
private static void addTask(String userInput) {
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 is quite long, splitting it up into separate functions(per task) would be better

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.

5 participants