Skip to content

[yangyi-zhu] iP - #174

Open
yangyi-zhu wants to merge 49 commits into
nus-cs2113-AY2425S2:masterfrom
yangyi-zhu:master
Open

[yangyi-zhu] iP#174
yangyi-zhu wants to merge 49 commits into
nus-cs2113-AY2425S2:masterfrom
yangyi-zhu:master

Conversation

@yangyi-zhu

Copy link
Copy Markdown

No description provided.

@LEESY02 LEESY02 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 think majority of the code looks good! I gave some minor edit suggestions, to give them some consideration :D

Comment thread src/main/java/Main.java Outdated
private static final Task[] list = new Task[100];

/**
public static void echo(String msg) {

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 commented code seems to be a snippet of code from a previous Level, perhaps it could be removed as it does not help the readers understand what is going on with your code.

Comment thread src/main/java/Main.java Outdated
public static void checkInput(String msg) {
if (msg.equals("list")) {
System.out.println(NL + DIVIDER + NL + "Tasks:");
for (int i = 0; i < count; 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.

Maybe you could refactor each of the if cases into a method

Instead of using multiple lines of else if, perhaps having a single case() switch will be easier to read as well

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

e.g.: the lines of code for the list function could be
if (msg.equals("list")) {
printList();
}
To simplify the method in general and making it easier to read

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

public static void main(String[] args) {
Scanner msg = new Scanner(System.in);
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 it would be easier to read if each of these print messages are encapsulated in a method, to make the main method shorter and more concise

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 e.g.:
public static void main(String[] args) {
Scanner msg = new Scanner(System.in);
printIntroMessage();
.......
printOutroMessage();
}

private static void printIntroMessage() {
sout("This is an intro message :D");
}
private static void printOutroMessage() {
sout("This is an outro message :D");
}

Comment thread src/main/java/Task.java Outdated
private String desc;
private boolean isDone;

// Type 0: To-do (default)

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 instead of using int type to identify the different sub tasks, could have Task as a parent class and the other subtasks as a children class

i.e.:
public class Task {
}
public class ToDo extends Task {
}

Using super classes' toString() in the child's classes' toString is an idea to automate the printing of each task
Task's toString: "[ ] Task A"
Child's toString: "[T]" + super.toString()
Of course this is a very simplified example, it is up to you on how you implement it

Comment thread src/main/java/Main.java Outdated
@@ -0,0 +1,94 @@
import java.util.Scanner;

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 it was a good read with all the functionalities, there is only a few things to touch up :D

Comment thread src/main/java/Baguette.java Outdated
@@ -1,4 +1,4 @@
public class Duke {
public class Baguette {

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 class name, oui oui baguette

@Rishi7830 Rishi7830 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/Main.java Outdated
msg + "\n" +
"-------------------------- \n");
Scanner newMsg = new Scanner(System.in);
echo(newMsg.nextLine());

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 commented code looks like a code of the previous level so remove it :) for better code quality

Comment thread src/main/java/Main.java Outdated
int type = 0; // defaults to to-do if no prefix
int index = 0;

if (msg.startsWith("todo ")) {

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 on not using the arrowhead style code style

Comment thread src/main/java/Task.java Outdated
// Type 2: Event
private int type;

public Task(String description, int 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.

Good job on structuring the code logically

Comment thread src/main/java/Main.java Outdated
System.out.println((i + 1) + ". " + list[i]);
}
System.out.println(DIVIDER + NL);
} else if (msg.startsWith("mark ")) {

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 on not using the arrowhead style code

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

@Override
public String toString() {
String typeBox = new String("");

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 your code structure

Comment thread src/main/java/Main.java Outdated
private static int count = 0;
private static final Task[] list = new Task[100];

public static void checkInput(String msg) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid lengthy methods. Keep the length of each method to about 30 lines of code.

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

@Override
public String toString() {
return getType() + (isDone ? "[✓] " : "[ ] ") + desc;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid usage of magic strings.

Comment thread src/main/java/Main.java Outdated
Comment on lines +62 to +72
System.out.println(
NL + DIVIDER + NL +
"The supported types and corresponding formats are as follows:" + NL +
"To-Dos: todo [description]" + NL +
"Deadlines: deadline [description] ddl: [DD-MM-YY HH:MM]" + NL +
"Events: event [description] from: [DD-MM-YY HH:MM] to: [DD-MM-YY HH:MM]" + NL +
NL + "Examples:" + NL +
"todo Do the laundry" + NL +
"deadline CS2113 Increment L5 ddl: 14-02-25 16:00" + NL +
"event Josh's birthday party from: 03-03-25 15:00 to: 04-03-25 00:00" +
NL + DIVIDER + NL

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since the print statements are common for many commands - you can consider creating a function instead of repeating the same code lines for each command

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