Skip to content

[Wang Zihan] iP - #94

Open
zihan9485 wants to merge 28 commits into
nus-cs2113-AY2021S2:masterfrom
zihan9485:master
Open

[Wang Zihan] iP#94
zihan9485 wants to merge 28 commits into
nus-cs2113-AY2021S2:masterfrom
zihan9485:master

Conversation

@zihan9485

Copy link
Copy Markdown

No description provided.

Comment thread src/main/java/Duke.java Outdated
//Level 3: Mark as Done
Scanner in = new Scanner(System.in);
String userInput;
Task[] taskList = new Task[100]; //TODO: Remove magic literals, refactor and extract constant

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agree with the TODOs here!

Comment thread src/main/java/Task.java Outdated
}

public String getStatusIcon() {
return (isDone ? "\u2713" : "\u2718");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Arbitrary unicode can be replaced by a more expressive constant instead

Comment thread src/main/java/Duke.java Outdated
lineBreak();
}

public static void lineBreak() {

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 use of method extraction for line breaks

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agree with the good use of lineBreak() on method extraction! Perhaps can create a class for all the miscellaneous output like this.

Comment thread src/main/java/Duke.java Outdated
String by = userInput.substring(dividerPosition + 4);
taskList[listCount++] = new Deadline(userInput.substring(9, dividerPosition - 1), by);
System.out.println(" " + taskList[listCount - 1].toString());
System.out.println("Now you have " + listCount + " tasks in the list.");

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 would be good practice to keep the indentation for wrapped lines to: 8 spaces more than the parent line.

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

public static void exitProgram() {
lineBreak();
System.exit(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.

Very clean code! Looks good to merge

@vaiish371 vaiish371 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, I found your code very clean and it seems to have followed 99% of the coding standard. I could hardly find any errors, so good job!

@liping-eng liping-eng 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, good use of camelCase for variables and methods. Good use K&R style brackets.

Comment thread src/main/java/Duke.java Outdated
lineBreak();
}

public static void lineBreak() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agree with the good use of lineBreak() on method extraction! Perhaps can create a class for all the miscellaneous output like this.

Comment thread src/main/java/Duke.java Outdated
Scanner in = new Scanner(System.in);
String userInput;
Task[] taskList = new Task[100];
Task[] taskList = new Task[100]; //TODO: Remove magic literals, refactor and extract constant

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perhaps change "taskList" to "tasks" (plural form) as it is representing a collection of objects.

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

public static final int MAX_TASK = 100;

static Task[] taskList = new Task[MAX_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.

Perhaps you can use plural variable name for representing the collection of Task objects. Even though taskList is quite clear and can be easily understood, use of plural word like "tasks" could better convey the meaning.

@vaiish371 vaiish371 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.

I have left you few more comments, that have to do with very minor errors - naming convention. Apart that, the code looks really clean!

@rafaelperes rafaelperes 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.

Good Job!

Comment thread src/main/java/duke/Deadline.java Outdated

@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";

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 should explore the use of constants here in order to reduce the need of magic strings.

Comment thread src/main/java/duke/Duke.java Outdated
Comment on lines +17 to +23
greet();
loadFile();
while (true) {
String userInput = SCANNER.nextLine();
executeCommand(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.

good use of abstractions here.

Comment thread src/main/java/duke/Duke.java Outdated
int dividerPosition;
char taskType = line.charAt(1);
switch (taskType) {
case 'T':

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

to improve code readability, maybe we should use enums here?

Comment thread src/main/java/duke/Duke.java Outdated
default:
System.out.println("Unknown task type found: " + taskType);
}
if (line.charAt(4) == '\u2713') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

refer to the magic strings comment.

Comment thread src/main/java/duke/Duke.java Outdated
char taskType = line.charAt(1);
switch (taskType) {
case 'T':
taskList.add(new Todo(line.substring(7)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what does line.substring(7) stand for? maybe we should assign a variable for it?

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