Skip to content

[kestryix] iP#96

Open
kestryix wants to merge 21 commits into
nus-cs2113-AY2425S1:masterfrom
kestryix:master
Open

[kestryix] iP#96
kestryix wants to merge 21 commits into
nus-cs2113-AY2425S1:masterfrom
kestryix:master

Conversation

@kestryix

@kestryix kestryix commented Sep 3, 2024

Copy link
Copy Markdown

No description provided.

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

case "unmark":
String[] split = input.split(" ");
int idx = Integer.parseInt(split[1]) - 1;

@telferang telferang Sep 4, 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.

Consider using more descriptive variable names, such as "index" instead of "idx", for better readability.

Comment thread src/main/java/TulipTask.java Outdated
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();

// if (Objects.equals(input.toLowerCase(), "bye")) {

@telferang telferang Sep 4, 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.

Consider removing the commented-out code if it is no longer needed for clarity and to keep the codebase clean.

Comment thread src/main/java/TulipTask.java Outdated
System.out.println("--------------------------------------------");
System.out.println("Hello, I'm TulipTask");
System.out.println("What can I do for you today?");
System.out.println("--------------------------------------------");

@telferang telferang Sep 4, 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.

Consider extracting the line as a public static final constant to improve maintainability and avoid duplication.

import java.util.Objects;
import java.util.Scanner;

public class TulipTask {

@telferang telferang Sep 4, 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.

Consider renaming the class to "Tulip" as "TulipTask" suggests it might inherit from a "Task" class, which can be misleading.

Comment thread src/main/java/Task.java
@@ -0,0 +1,21 @@
public class Task {
protected String description;
protected boolean isDone;

@telferang telferang Sep 4, 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.

The boolean variable name "isDone" is well-named, as it clearly indicates its purpose and state.

@louisjoety louisjoety 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 overall, just a few nits to fix. Keep it up @kestryix! 🚀

Comment thread src/main/java/TulipTask.java Outdated
Comment on lines +50 to +63
switch(command) {
case "list":
listTasks(list);
break;

case "mark":
String[] splitStr = input.split(" ");
int index = Integer.parseInt(splitStr[1]) - 1;
markAsDone(list.get(index));
break;

case "unmark":
String[] split = input.split(" ");
int idx = Integer.parseInt(split[1]) - 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.

Maybe avoid different levels of abstraction here (i.e.listTasks(list) and String[] splitStr = input.split(" ") and int index = Integer.parseInt(splitStr[1]) - 1

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

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 make the code more explicit here instead of using ternary if operator?

import java.util.Objects;
import java.util.Scanner;

public class TulipTask {

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 class naming as it is not too long and not short. Nice work!

System.out.println("Okay, I have marked this task as not done: \n" + " [" + task.getStatusIcon() + "] " + task.description);
System.out.println("--------------------------------------------");
}
}

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 may consider adding comment statements here to explain to other engineers what and why you are doing this.

Comment thread src/main/java/TulipTask.java Outdated
System.out.println("--------------------------------------------");
System.out.println("Great job! I have marked this task as done: \n" + " [" + task.getStatusIcon() + "] " + task.description);
System.out.println("--------------------------------------------");
}

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 need to fix the spacings here.

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

Great work! Just some comments mainly on the standards to use in this course.

String type = line.substring(1, 2);
boolean completed = line.charAt(4) == 'X';

switch (type) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For your switch statements, maybe you could follow the style mentioned here.

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

public class TulipTask {
public static void main(String[] args) throws TulipTaskException.InvalidTaskDescriptionException, TulipTaskException.InvalidEndDateException, TulipTaskException.InvalidStartDateException, TulipTaskException.InvalidDeadlineException, TulipTaskException.InvalidTaskIndexException {
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.

Excellent job on storing these strings and not using them as Magic strings!

Comment thread src/main/java/TulipTask.java Outdated
String command = commandArguments.get(InputParser.COMMAND);

switch (command) {
case "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.

Maybe you could refactor to avoid magic strings!

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

public class TulipTask {
public static void main(String[] args) throws TulipTaskException.InvalidTaskDescriptionException, TulipTaskException.InvalidEndDateException, TulipTaskException.InvalidStartDateException, TulipTaskException.InvalidDeadlineException, TulipTaskException.InvalidTaskIndexException {

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 main method seems quite long, maybe you could refactor it to several smaller methods!


public void parseTask(String line) {
String type = line.substring(1, 2);
boolean completed = line.charAt(4) == 'X';

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 naming of your boolean can be improved to sound like a boolean!

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