Skip to content

[LimHongYao] iP#201

Open
LimHongYao wants to merge 30 commits into
nus-cs2113-AY2223S2:masterfrom
LimHongYao:master
Open

[LimHongYao] iP#201
LimHongYao wants to merge 30 commits into
nus-cs2113-AY2223S2:masterfrom
LimHongYao:master

Conversation

@LimHongYao

Copy link
Copy Markdown

Renamed Duke
Added ToDoList functionality (add, mark, unmark, show list)
Given some personality

Changed Duke's Name
Improved handling of commands by splitting user input
Changed to use Tasks classes
@LimHongYao LimHongYao changed the title Add ToDoList functionality to Duke (now known as Anna) [LimHongYao] iP Jan 31, 2023

@khooyourun khooyourun left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overall, the code is readable and the if statements are not deeply nested.

Comment thread src/main/java/Duke.java Outdated
boolean exit = false;
while (!exit) {
String input = (in.nextLine()).trim();
String inputCMD, inputItem;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can I check what does CMD mean? If it stands for command. I think it's better to just name it as inputCommand for readibilty.

Comment thread src/main/java/Duke.java Outdated
Comment on lines +18 to +19
inputCMD = input.split(" ", 2)[0];
inputItem = input.split(" ", 2)[1];

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 numbers like 2, 0, 1 might be considered magic numbers that hinder readability.

Comment thread src/main/java/ToDoList.java Outdated
}
}
public static void markDone (int index) {
if (TaskList.get(index).getStatusIcon().equals(" ")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this if statement necessary? I think markDone would change the status icon to "X" independent of what is originally is

Comment thread src/main/java/Duke.java Outdated
Comment on lines +45 to +47
ToDoList.markDone(Integer.parseInt(inputItem)-1);
System.out.println("Okay I've marked item " + inputItem + " as done:");
ToDoList.printItem(Integer.parseInt(inputItem)-1);

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 like the single level of abstraction applied here. Makes things easy to follow

Comment thread src/main/java/Duke.java Outdated
System.out.println("Hi it's Anna!\nWhat do you need to do?");
Scanner in = new Scanner(System.in);

boolean exit = 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.

Preferably name boolean in such a way that implies it is boolean.

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 use isExit to replace exit can imply a boolean

@liuziyang020319 liuziyang020319 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Most the codes follow the coding standard

Comment thread src/main/java/Duke.java Outdated
System.out.println("Hi it's Anna!\nWhat do you need to do?");
Scanner in = new Scanner(System.in);

boolean exit = 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.

Maybe use isExit to replace exit can imply a boolean

Comment thread src/main/java/ToDoList.java Outdated
import java.util.ArrayList;

public class ToDoList {
private static final ArrayList<Task> TaskList = new ArrayList<>(10);

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 V\variable names need to be in camelCase.

Comment thread src/main/java/ToDoList.java Outdated
import java.util.ArrayList;

public class ToDoList {
private static final ArrayList<Task> TaskList = new ArrayList<>(10);

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 variable names need to be in camelCase.

Comment thread src/main/java/ToDoList.java Outdated

public class ToDoList {
private static final ArrayList<Task> TaskList = new ArrayList<>(10);
private static int NumTasks = 0;

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 variable names must be in camelCase, same problem.

Comment thread src/main/java/ToDoList.java Outdated
import java.util.ArrayList;

public class ToDoList {
private static final ArrayList<Task> TaskList = new ArrayList<>(10);

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 the size of the ArrayList should be a magic number.

Comment thread src/main/java/Duke.java Outdated
import java.util.Scanner;

public class Duke {
static final int COMMAND_INDEX = 0;

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 job using constants for your numbers! You could extend that to magic strings as well!

Comment thread src/main/java/Duke.java Outdated
TaskList.viewList();
}
break;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do avoid leaving the space between each case as per the Java Coding Standards

Comment thread src/main/java/Task.java
public String getTypeIcon() {
return "NULL";
}
public String taskTypeIcon() { return "[" + getTypeIcon() + "]";}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Even though these are simple 1 liners, please do still follow the proper style (aka Egyptian Style).

import java.util.ArrayList;

public class TaskList {
private static final ArrayList<Task> TaskList = new ArrayList<>(10);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ArrayList is a type of dynamic array and there is no need to limit your TaskList to a size of 10 only!

System.out.println(TaskList.get(i).getTask());
}
}
public static void markDone (int index) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There should not be a space between markDone and (. Do change this for your other methods as well :)

Comment thread src/main/java/Task.java
protected String description;
protected boolean isDone;

public Task(String description) { //ok to leave as public?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes you need to leave it as public. But do remove such comments from your code as it goes against the java coding standard. 👍

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.

4 participants