Skip to content

[Sim Jia Ming] iP#316

Open
SimJM wants to merge 57 commits into
nus-cs2103-AY2122S2:masterfrom
SimJM:master
Open

[Sim Jia Ming] iP#316
SimJM wants to merge 57 commits into
nus-cs2103-AY2122S2:masterfrom
SimJM:master

Conversation

@SimJM
Copy link
Copy Markdown

@SimJM SimJM commented Feb 1, 2022

Duke frees your mind of having to remember things you need to do. It's,

  • text-based
  • easy to learn
  • FAST SUPER FAST to use
    All you need to do is,
  1. download it from here.
  2. double-click it.
  3. add your tasks.
  4. let it manage your tasks for you 💯

its FREE

tasklist:

  • done
  • not done

Here's the main method:

public class Main {
   public static void main(String[] args) {
       Application.launch(MainApp.class, args);
   }
}

@SimJM SimJM changed the title Sim Jia Sim Jia Ming iP Feb 1, 2022
@SimJM SimJM changed the title Sim Jia Ming iP [Sim Jia Ming] iP Feb 1, 2022
Copy link
Copy Markdown

@tyanhan tyanhan left a comment

Choose a reason for hiding this comment

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

Good job overall, I did not notice any basic styling errors. You can improve your code by breaking down long parts into separate functions. All the best!

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

@Override
String getSym() {
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 would opt for a more intuitive name rather than sym.

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 would opt for a more intuitive name rather than sym.

Maybe you can change it to a more descriptive name such as symbol?

Comment thread src/main/java/Duke.java Outdated
String phrase = sc.nextLine();
System.out.println(DASH);

if (phrase.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.

Perhaps you can consider using a switch statement instead?

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 code here is pretty long, but you will get to break it down later as you progress with the iP. Consider doing the printing in separate functions and get your switch statement to invoke those print functions instead.

Comment thread src/main/java/Duke.java Outdated
String noOfTask = String.format("Now you have %d tasks in the list.", arrlst.size());
System.out.println(noOfTask);
}
} catch (ArrayIndexOutOfBoundsException aioobe) { // echo
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can consider changing the parameter name to just e instead.

Copy link
Copy Markdown

@yongler yongler left a comment

Choose a reason for hiding this comment

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

LGTM! Just some minor nits to fix

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

It is possible to change Task to an abstract class?

Comment thread src/main/java/Action.java Outdated
@@ -0,0 +1,35 @@
import java.util.ArrayList;

public class Action {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks clean!

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

@Override
String getSym() {
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 would opt for a more intuitive name rather than sym.

Maybe you can change it to a more descriptive name such as symbol?

Comment thread src/main/java/Duke.java Outdated
System.out.println("Hello from\n" + logo);
Scanner sc = new Scanner(System.in);
ArrayList<Task> arrlst = new ArrayList<>();
String DASH = "____________________________________________________________";
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 works too, but UI can be separated into a class for cleanliess

Copy link
Copy Markdown

@jetrz jetrz left a comment

Choose a reason for hiding this comment

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

Generally clean code, well documented, styled, and easy to understand. Only minor nitpicks in terms of documentation and code logic here and there. Well done!

Comment thread src/main/java/Task.java Outdated
Comment on lines +6 to +43
public Task(String description) {
this.description = description;
this.isDone = false;
this.sym = " ";
}

public Task(String description, String sym) {
this.description = description;
this.isDone = false;
this.sym = sym;
}

public String getStatusIcon() {
return (isDone ? "X" : " "); // mark done task with X
}

public void markAsDone() {
this.isDone = true;
System.out.println("Nice! I've marked this task as done:");
String output = String.format(" [%s][%s] %s", this.sym, this.getStatusIcon(), this.description);
System.out.println(output);
}

public void markAsNotDone() {
this.isDone = false;
System.out.println("OK, I've marked this task as not done yet:");
String output = String.format(" [%s] %s", this.getStatusIcon(), this.description);
System.out.println(output);
}

String getSym() {
return this.sym;
}

@Override
public String toString() {
return String.format("added: %s", description);
}
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 use some javadocs documentation as Task is the parent class.

Comment thread src/main/java/Duke.java Outdated
Comment on lines +79 to +88
for (int i = 1; i < arrWords.length; i++) {
if (arrWords[i].equals("/at")) {
for (int j = i + 1; j < arrWords.length; j++) {
dayAndTime = dayAndTime + " " + arrWords[j];
}
break;
} else {
remainingWords = remainingWords + " " + arrWords[i];
}
}
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 use comments in places like these to explain what the code is doing (i.e. splitting up the user input) as it may not be apparent on first sight.

Comment thread src/main/java/Action.java Outdated
Comment on lines +21 to +28
void showList(ArrayList<Task> arrlst) {
System.out.println("Here are the tasks in your list:");
for (int i = 0; i < arrlst.size(); i++) {
String output = String.format("%d.[%s][%s]%s\n", i + 1, arrlst.get(i).sym,
arrlst.get(i).getStatusIcon(), arrlst.get(i).description);
System.out.println(output);
}
}
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 use a javadocs documentation.

Comment thread src/main/java/Event.java Outdated
Comment on lines +10 to +13
@Override
String getSym() {
return this.sym;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

May I check what is the purpose of this override? Same with deadline and todo classes. Seems redundant as the getSym() in Task is the same.

Comment thread src/main/java/Task.java Outdated
@@ -0,0 +1,45 @@
public class Task {
protected String description;
Copy link
Copy Markdown

@KwanHW KwanHW Feb 3, 2022

Choose a reason for hiding this comment

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

While protected may appear sufficient, these attributes can still be accessible by other functions once you start putting them into packages. Consider changing your attributes to private

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

@Override
public String toString() {
return String.format("added: %s", description);
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 you should change your toString() method to print out the sym, isDone and description instead of this message. This can reduce code duplication in your children classes as I observed that they are using attributes in Task to form the string.

Comment thread src/main/java/Task.java Outdated
System.out.println(output);
}

String getSym() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing public keyword at function signature

@KwanHW
Copy link
Copy Markdown

KwanHW commented Feb 3, 2022

Good effort overall.

Some improvements to consider:

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