Skip to content

[Lim Yuh Ching] iP#79

Open
limyuhching wants to merge 26 commits into
nus-cs2113-AY2324S1:masterfrom
limyuhching:master
Open

[Lim Yuh Ching] iP#79
limyuhching wants to merge 26 commits into
nus-cs2113-AY2324S1:masterfrom
limyuhching:master

Conversation

@limyuhching

Copy link
Copy Markdown

No description provided.

ToDos, Events, Deadlines are created as a subclass of Task.

Moved addToTask and printTask from Task class to Main program.

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

Overall code is easy to read, little to no standard coding violations. Everything looks good to me

Comment thread src/main/java/Deadlines.java Outdated
@@ -0,0 +1,18 @@
public class Deadlines extends Task {
String by;

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 following of spacing requirements

Comment thread src/main/java/Duke.java Outdated
private static int taskCount = 0;

public static void addToTasks(String description, Type type) {
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.

Good and clear use of switch statements

Comment thread src/main/java/Duke.java Outdated
System.out.println("\tNow you have " + taskCount + " task(s) in the list.");
}
public static void printTasks() {
if (taskCount == 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.

Good use of if-statements, no nesting errors

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

Missed out 1 comment previously, everything looks good to me

Comment thread src/main/java/Deadlines.java Outdated
super(description);
this.by = by;
}
public String getBy() {

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 following of naming of method conventions

@DextheChik3n DextheChik3n 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 really like how you structure your code! I just made some suggestions to the variable name to make your code more clear to understand

Comment thread src/main/java/Duke.java Outdated
Scanner scanner = new Scanner(System.in);
String userInput = scanner.nextLine();
String[] substr = userInput.split("\\s+");
switch (substr[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.

command handling is well-organised using a switch case which makes it easier to troubleshoot.

Comment thread src/main/java/Duke.java Outdated
}
}
}
public static void bye() {

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 could use a more clear method name such as printByeMessage?

Suggested change
public static void bye() {
public static void printByeMessage() {

Comment thread src/main/java/Duke.java Outdated
tasks[taskCount] = new ToDos(description);
break;
case DEADLINE:
int i = description.indexOf("/");

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 use a better variable name for the index like indexAfterBy? so that it is more clearer when you revisit the code

@yicheng-toh yicheng-toh 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.

Looks good and neat!

Comment thread src/main/java/Duke.java Outdated
Comment on lines +66 to +87
case "bye":
bye();
break;
case "list":
printTasks();
break;
case "mark":
markAsDone(Integer.parseInt(substr[1]));
break;
case "unmark":
markAsUndone(Integer.parseInt(substr[1]));
break;
case "todo":
addToTasks(userInput.substring(5), Type.TODO);
break;
case "deadline":
addToTasks(userInput.substring(9), Type.DEADLINE);
break;
case "event":
addToTasks(userInput.substring(6), Type.EVENT);
break;
}

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 how you use switch statements for the various instructions. This makes your code very neat.

Comment thread src/main/java/Task.java
this.description = description;
}

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.

Perhaps the method could sound more verb-like?

Suggested change
public boolean isDone() {
public boolean checkIsDone() {

Comment thread src/main/java/Type.java
Comment on lines +1 to +3
public enum Type {
TODO, DEADLINE, EVENT
}

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 use of enum for the various tasks!

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

Overall, your code follows the standards decently. However, do look out for things like naming conventions and magic types which can be avoided and will help to improve your code.

Comment thread src/main/java/Duke.java Outdated
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
// Greetings
String intro = "~~~~~~~~~~~~~~~~~~~\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.

Perhaps this could be made a constant.

Comment thread src/main/java/Duke.java Outdated
Comment on lines +18 to +19
int j = description.indexOf("/");
int k = description.indexOf("/", j+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.

For the following methods, you could use more descriptive variables rather than single letter variables. This would be more in line with the naming conventions required.

The name change suggested by your classmate would be a good example of how to name the variable instead!

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