Skip to content

[Feng Guangyao] iP#69

Open
MrOPPA1 wants to merge 50 commits into
nus-cs2113-AY2324S1:masterfrom
MrOPPA1:master
Open

[Feng Guangyao] iP#69
MrOPPA1 wants to merge 50 commits into
nus-cs2113-AY2324S1:masterfrom
MrOPPA1:master

Conversation

@MrOPPA1

@MrOPPA1 MrOPPA1 commented Sep 5, 2023

Copy link
Copy Markdown

just for test

@MrOPPA1 MrOPPA1 closed this Sep 5, 2023
@MrOPPA1 MrOPPA1 changed the title just for test [Feng Guangyao] iP Sep 5, 2023
@MrOPPA1 MrOPPA1 reopened this Sep 5, 2023
Comment thread src/main/java/Duke.java Outdated
Comment on lines +62 to +97
switch (firstCommand) {
case "bye": {
running = false;
break;
}
case "todo": {
Task newTask = new Todo(input.substring(5, input.length()));
insertTask(newTask);
break;
}
case "deadline": {
int[] dividerPositions = new int[] { input.indexOf("/") };
Task newTask = new Deadline(input.substring(9, dividerPositions[0] - 1),
input.substring(dividerPositions[0] + 4, input.length()));
insertTask(newTask);
break;
}
case "event": {
int[] dividerPositions = new int[] { input.indexOf("/"), 0 };
// Try to find the second "/"
String remainingString = input.substring(dividerPositions[0] + 1, input.length());
dividerPositions[1] = dividerPositions[0] + 1 + remainingString.indexOf("/");
Task newTask = new Event(input.substring(6, dividerPositions[0] - 1),
input.substring(dividerPositions[0] + 6, dividerPositions[1] - 1),
input.substring(dividerPositions[1] + 3, input.length()));
insertTask(newTask);
break;
}
case "list": {
showTasks();
break;
}
default: {
showLog(input);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Switch case statement does not follow the coding standard

Comment thread src/main/java/Duke.java Outdated
Comment on lines +80 to +86
int[] dividerPositions = new int[] { input.indexOf("/"), 0 };
// Try to find the second "/"
String remainingString = input.substring(dividerPositions[0] + 1, input.length());
dividerPositions[1] = dividerPositions[0] + 1 + remainingString.indexOf("/");
Task newTask = new Event(input.substring(6, dividerPositions[0] - 1),
input.substring(dividerPositions[0] + 6, dividerPositions[1] - 1),
input.substring(dividerPositions[1] + 3, input.length()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These lines can be quite confusing and not very readable. Perhaps renaming the dividerPositions to another name would be better. Similar cases throughout.

Comment thread src/main/java/Main.java Outdated
Comment on lines +1 to +16
public class Main {
public static void main(String[] args) {
// create a todo task and print it
Todo t = new Todo("Read a good book");
System.out.println(t);
// change todo fields and print again
t.setDone(true);
System.out.println(t);
// create a deadline task and print it
Deadline d = new Deadline("Read textbook", "Nov 16");
System.out.println(d);
// change deadline details and print again
d.setDone(true);
d.setBy("Postponed to Nov 18th");
System.out.println(d);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not sure what is the main reason for this class as a main method is already written in Duke.java. Would it be for testing? Perhaps using the appropriate platform for testing would be better.

Comment thread src/main/java/Deadline.java Outdated
Comment on lines +4 to +9
public Deadline(String description, String by) {
super(description);
this.by = by;
isDone = false;
type = "D";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perheps you can change the parameter by to some noun phrase to be more clear. The type = 'D' looks a bit confusing, especially if the reviwer don't know we need to print out the type of task as 'D'.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

actually you could rename it as taskType

Comment thread src/main/java/Duke.java Outdated
showLog("Bye. Hope to see you again soon!");
}

public static void showLog(Object content) {

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 know the meaning of showLog? Maybe you can extend it to full name if it is just some short phrase

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

public class Duke {
static Task[] tasks = new Task[1000];
static int amount = 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.

The variable amount keeps track of the number of tasks, right? I would suggest using taskCount instead.

Comment thread src/main/java/Duke.java Outdated
Comment on lines +62 to +97
switch (firstCommand) {
case "bye": {
running = false;
break;
}
case "todo": {
Task newTask = new Todo(input.substring(5, input.length()));
insertTask(newTask);
break;
}
case "deadline": {
int[] dividerPositions = new int[] { input.indexOf("/") };
Task newTask = new Deadline(input.substring(9, dividerPositions[0] - 1),
input.substring(dividerPositions[0] + 4, input.length()));
insertTask(newTask);
break;
}
case "event": {
int[] dividerPositions = new int[] { input.indexOf("/"), 0 };
// Try to find the second "/"
String remainingString = input.substring(dividerPositions[0] + 1, input.length());
dividerPositions[1] = dividerPositions[0] + 1 + remainingString.indexOf("/");
Task newTask = new Event(input.substring(6, dividerPositions[0] - 1),
input.substring(dividerPositions[0] + 6, dividerPositions[1] - 1),
input.substring(dividerPositions[1] + 3, input.length()));
insertTask(newTask);
break;
}
case "list": {
showTasks();
break;
}
default: {
showLog(input);
}
}

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 way that you try to group the whole things as OO style.

Comment thread src/main/java/Todo.java Outdated
type = "T";
}

public boolean isDone() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

isDone is a verb phrase. I guess you want to return get the isDone field. It would be better if you could use "getisDone" or "getFinishStatus", sth. like these.

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