Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LimHongYao] iP #201

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

Conversation

LimHongYao
Copy link

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
Copy link

@khooyourun khooyourun 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 is readable and the if statements are not deeply nested.

boolean exit = false;
while (!exit) {
String input = (in.nextLine()).trim();
String inputCMD, inputItem;

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 on lines 18 to 19
inputCMD = input.split(" ", 2)[0];
inputItem = input.split(" ", 2)[1];

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.

}
}
public static void markDone (int index) {
if (TaskList.get(index).getStatusIcon().equals(" ")) {

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 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);

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

System.out.println("Hi it's Anna!\nWhat do you need to do?");
Scanner in = new Scanner(System.in);

boolean exit = false;

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.

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

Copy link

@liuziyang020319 liuziyang020319 left a comment

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

System.out.println("Hi it's Anna!\nWhat do you need to do?");
Scanner in = new Scanner(System.in);

boolean exit = false;

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

import java.util.ArrayList;

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

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.

import java.util.ArrayList;

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

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.


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

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.

import java.util.ArrayList;

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

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.

public class Duke {
static final int COMMAND_INDEX = 0;
Copy link

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!

TaskList.viewList();
}
break;

Copy link

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

public String getTypeIcon() {
return "NULL";
}
public String taskTypeIcon() { return "[" + getTypeIcon() + "]";}
Copy link

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

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

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 :)

protected String description;
protected boolean isDone;

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

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