Skip to content

[yuhengr] ip#193

Open
yuhengr wants to merge 49 commits into
nus-cs2113-AY2324S2:masterfrom
yuhengr:master
Open

[yuhengr] ip#193
yuhengr wants to merge 49 commits into
nus-cs2113-AY2324S2:masterfrom
yuhengr:master

Conversation

@yuhengr

@yuhengr yuhengr commented Feb 9, 2024

Copy link
Copy Markdown

No description provided.

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

Nice work! Overall, the code follows the code quality guidelines. Naming of variables & methods are appropriate, and the code is readable with the exception of some long lines.

Comment thread src/main/java/Duke.java Outdated
int fromPosition = userInput.indexOf("/from");
int toPosition = userInput.indexOf("/to");

tasks[taskCount] = new Event(userInput.substring(dividerPosition + 1, fromPosition - 1), userInput.substring(fromPosition + 6, toPosition - 1), userInput.substring(toPosition + 4));

@webtjs webtjs Feb 9, 2024

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 consider line wrapping? This line seems quite long.

Comment thread src/main/java/Duke.java Outdated
else if(words[0].equals("deadline")){
int dividerPosition = userInput.indexOf(" ");
int slashPosition = userInput.indexOf("/by");
tasks[taskCount] = new Deadline(userInput.substring(dividerPosition + 1, slashPosition - 1), userInput.substring(slashPosition + 4));

@webtjs webtjs Feb 9, 2024

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 consider line wrapping for this line also?

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

String userInput;
Scanner in = new Scanner(System.in);
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.

I like the use of plural form to indicate multiple tasks

Comment thread src/main/java/Duke.java Outdated
@@ -6,5 +8,72 @@ public static void main(String[] args) {
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";

@webtjs webtjs Feb 9, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should the logo variable be deleted since it's not used?

Comment thread src/main/java/Task.java
Comment on lines +10 to +20
public String getStatusIcon() {
return (isDone ? "X" : " ");
}

public void markAsDone() {
this.isDone = true;
}

public void markAsNotDone() {
this.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.

Method names are good as they sound like verbs

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

Hi Yu Heng,

Try to avoid using magic literals in your program, this is a code quality requirement!
Do consider refactoring some parts of your code that are very long. This will help in readability!

There are some other specific comments below. Try and fix them before the next tutorial!

For your consideration: There is a way to autoformat your code automatically every time you Ctrl-S on intellij which will save you much pain. :)

Comment thread src/main/java/Deadline.java Outdated
@@ -0,0 +1,14 @@
public class Deadline extends 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.

Formatting error with the curly brace!

Comment thread src/main/java/Duke.java Outdated
public class Duke {
public static void main(String[] args) {
/*
String logo = " ____ _ \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.

Ditto with the comment by your peer. Remove code that is commented out!

Comment thread src/main/java/Duke.java Outdated
String userInput;
Scanner in = new Scanner(System.in);
ArrayList<Task> tasks = new ArrayList<>();
// 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.

Remove unused code, please.

Comment thread src/main/java/Duke.java Outdated
while(!userInput.equals("bye")){
String[] userInputWords = userInput.split(" ");

if(userInput.equals("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.

This if-else chain is nested and very long. This usually hints that there can be room for improvement for making your code SLAP more.

To aid you in achieving SLAP, here are some guiding questions...

  1. What parts of the code is repetitive? i.e. virtually the same for each if/else block you have
  2. What part of the code does a particular function that can be isolated into a function?

Comment thread src/main/java/Duke.java Outdated
int fromPosition = userInput.indexOf("/from");
int toPosition = userInput.indexOf("/to");

tasks.add(new Event(userInput.substring(dividerPosition + 1, fromPosition - 1), userInput.substring(fromPosition + 6, toPosition - 1), userInput.substring(toPosition + 4)));

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 is pretty hard to read, especially with all the magic literals. Do refactor your magic literals. You can consider breaking this up into a function!

Comment thread src/main/java/Event.java Outdated
@@ -0,0 +1,15 @@
public class Event extends 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.

Formatting error with the curly brace!

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.

3 participants