Skip to content

[Thomas Cherian] iP #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

tomascherian
Copy link

No description provided.

@@ -0,0 +1,17 @@
public class Deadline extends Task{
private final String dateTime;
Copy link

Choose a reason for hiding this comment

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

Var declares as final may need to be in all capital letters, eg: DATE_TIME

@@ -0,0 +1,17 @@
public class Event extends Task {
private final String dateTime;
Copy link

Choose a reason for hiding this comment

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

final var too 😄

String input = sc.nextLine();
try {
String[] inputArray = input.split(" ", 2);
String firstword = inputArray[0].toLowerCase();
Copy link

Choose a reason for hiding this comment

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

name as firstWord maybe better

default:
keyword = Keyword.ERROR;
break;
}

Choose a reason for hiding this comment

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

can consider using a hashmap to lookup the right Keyword given a string? same functionality but may save some lines, may look slightly more readable as well, but it's up to you

break;
case ERROR:
throw new PacException("I don't know what this means");
}

Choose a reason for hiding this comment

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

can consider rewriting these lines of code into separate functions to avoid deep nesting

Copy link

@manu2002g manu2002g left a comment

Choose a reason for hiding this comment

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

I noticed that there aren't any JavaDoc comments and maybe you should consider adding them to make your code easier to understand.
But overall great code quality that is quite readable! :)

Comment on lines 5 to 10
static String logo = " ____ ___ _____\n"
+ "| _ \\ / _ \\ | ___|\n"
+ "| |_| | | |_| | | |\n"
+ "| __/ | | | | | |___\n"
+ "|_| |_| |_| |_____|\n";
static String newline = "----------------------------------------------------";
Copy link

@manu2002g manu2002g Feb 5, 2022

Choose a reason for hiding this comment

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

Should the logo and newline variables be made final? And their names changed to fit the coding standard for naming constants eg: LOGO

String firstword = inputArray[0].toLowerCase();
Keyword keyword;

switch (firstword) {

Choose a reason for hiding this comment

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

The coding standard says that we shouldn't indent the case statements under switch I think it's possible to configure IntelliJ to follow this by default.

break;
}

switch (keyword) {

Choose a reason for hiding this comment

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

The case statements here should also not be intended

Comment on lines 160 to 171
String[] inputArray = input.split("/");
inputArray[1] = inputArray[1].replaceFirst("BY ", "by ");
inputArray[1] = inputArray[1].replaceFirst("By ", "by ");
inputArray[1] = inputArray[1].replaceFirst("bY ", "by ");
inputArray[1] = inputArray[1].split("by ", 2)[1];
if (inputArray[1].isBlank()) {
throw new PacException("Please enter a valid date or time.");
}
Task task = new Deadline(inputArray[0], inputArray[1]);
tasks.add(task);
System.out.println(newline + "\nadded: " + task.toString());
System.out.println("You have " + tasks.size() + " tasks in your list" + "\n" + newline + "\n");

Choose a reason for hiding this comment

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

Maybe you can add a few blank lines in this code block to make it more readable? The coding standard suggest that "Logical units within a block should be separated by one blank line." Perhaps you could add blank lines to separate the code into sections dealing with formatting, processing and output.

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