-
Notifications
You must be signed in to change notification settings - Fork 269
[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
base: master
Are you sure you want to change the base?
[Thomas Cherian] iP #274
Conversation
Rename Duke to Pac
Add enum Keyword
src/main/java/Deadline.java
Outdated
@@ -0,0 +1,17 @@ | |||
public class Deadline extends Task{ | |||
private final String dateTime; |
There was a problem hiding this comment.
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
src/main/java/Event.java
Outdated
@@ -0,0 +1,17 @@ | |||
public class Event extends Task { | |||
private final String dateTime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final var too 😄
src/main/java/Pac.java
Outdated
String input = sc.nextLine(); | ||
try { | ||
String[] inputArray = input.split(" ", 2); | ||
String firstword = inputArray[0].toLowerCase(); |
There was a problem hiding this comment.
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
src/main/java/Pac.java
Outdated
default: | ||
keyword = Keyword.ERROR; | ||
break; | ||
} |
There was a problem hiding this comment.
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
src/main/java/Pac.java
Outdated
break; | ||
case ERROR: | ||
throw new PacException("I don't know what this means"); | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this 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! :)
src/main/java/Pac.java
Outdated
static String logo = " ____ ___ _____\n" | ||
+ "| _ \\ / _ \\ | ___|\n" | ||
+ "| |_| | | |_| | | |\n" | ||
+ "| __/ | | | | | |___\n" | ||
+ "|_| |_| |_| |_____|\n"; | ||
static String newline = "----------------------------------------------------"; |
There was a problem hiding this comment.
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
src/main/java/Pac.java
Outdated
String firstword = inputArray[0].toLowerCase(); | ||
Keyword keyword; | ||
|
||
switch (firstword) { |
There was a problem hiding this comment.
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.
src/main/java/Pac.java
Outdated
break; | ||
} | ||
|
||
switch (keyword) { |
There was a problem hiding this comment.
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
src/main/java/Pac.java
Outdated
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"); |
There was a problem hiding this comment.
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.
Add data/ to .gitignore
# Conflicts: # src/main/java/Pac.java
No description provided.