-
Notifications
You must be signed in to change notification settings - Fork 484
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
[Lee Bing Heng] iP #565
base: master
Are you sure you want to change the base?
[Lee Bing Heng] iP #565
Conversation
@@ -20,6 +20,7 @@ enum Type { | |||
DEADLINE("deadline"), | |||
EVENT("event"), | |||
DELETE("delete"), | |||
FIND("find"), |
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.
Great that you have implemented enums to keep track of the long list of keywords!
protected Response find(String keyword) throws DukeException { | ||
ArrayList<String> output = new ArrayList<>(); | ||
output.add("Here are the matching tasks in your list:"); | ||
|
||
int count = 0; | ||
for (Task task : this.tasks) { | ||
if (task.name().contains(keyword)) { | ||
output.add(String.format("%d.%s", ++count, task.toString())); | ||
} | ||
} | ||
if (count == 0) { | ||
throw new TaskNotFoundException(); | ||
} | ||
return Response.generate(output); | ||
} |
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.
Very short and clear code!
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.
LGTM. Overall I feel the code is short and apt.
However, I do feel that it could be better abstracted into more packages.
src/main/java/duke/Duke.java
Outdated
@@ -0,0 +1,10 @@ | |||
package duke; | |||
|
|||
import duke.Utils.Session; |
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.
are the packages supposed to be in lower case format?
+ ":00"; | ||
return LocalDateTime.parse(timeSequence); | ||
} | ||
} |
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.
Great use of Command.java
package duke.Utils; | ||
|
||
/** | ||
* The DukeException class is a custom runtime exception class for handling exceptions | ||
* specific to the Duke application. | ||
* It extends the RuntimeException class and includes a custom error message. | ||
*/ | ||
public class DukeException extends RuntimeException { | ||
|
||
private String errorMessage; | ||
|
||
/** | ||
* Constructs a new DukeException with a custom error message. | ||
* | ||
* @param errorMessage The custom error message to be associated with the exception. | ||
*/ | ||
protected DukeException(String errorMessage) { | ||
this.errorMessage = errorMessage; | ||
} | ||
|
||
/** | ||
* Returns a string representation of the DukeException, including an error message. | ||
* | ||
* @return A string containing the error message preceded by "OOPS!!!". | ||
*/ | ||
@Override | ||
public String toString() { | ||
return "OOPS!!! " + errorMessage; | ||
} | ||
} |
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.
How about having different package just for exceptions?
assertThrows(InvalidArgumentException.class, () -> Command.assertDateTime(string, testCommand)); | ||
} | ||
} | ||
} |
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.
Great to see intensive code testing.
enum Type { | ||
TODO("[T]", 3), | ||
DEADLINE("[D]", 4), | ||
EVENT("[E]", 5); |
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.
Great use of enums here!
Improved code quality
into smaller, readable, maintainable code Fixed bugs pertaining to resizing of textbox generated from Duke Added assertions in command to ensure custom assertions to be working as expected
Refactoring Session.java: Segmented initializeUI
Branch bcd extension
BudgetDuke
How to use
public static void main (String[] args) { Duke.die(); }
😃
My repo