-
Notifications
You must be signed in to change notification settings - Fork 482
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
Open
starrylight99
wants to merge
41
commits into
nus-cs2103-AY2324S1:master
Choose a base branch
from
starrylight99:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Lee Bing Heng] iP #565
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
28ad2b8
Add Gradle support
ed6d4d2
Bump gradle and lib version
Eclipse-Dominator b25d3fc
Level-0
starrylight99 ab429f2
Level-1
starrylight99 5d0b01b
Level-1
starrylight99 5cff248
Level-2
starrylight99 4bcfb6d
Level-3
starrylight99 5b04fb0
save
starrylight99 846244f
Level-5
starrylight99 4d6ba07
Level-6
starrylight99 148378c
Level-7
starrylight99 6bd8f78
Added .gitkeep /data
starrylight99 4928ea2
Level-8
starrylight99 75cadb5
Merge branch 'add-gradle-support'
starrylight99 b3d5ded
A-Gradle
starrylight99 374f03c
A-JUnit
starrylight99 e54726b
A-Jar
starrylight99 d3b2b46
A-JavaDoc
starrylight99 191dc4e
A-CodingStandard
starrylight99 912cb5f
Level-9
starrylight99 e11d0a1
A-CheckStyle
starrylight99 feb6a69
Level-10
starrylight99 11c0197
Level-10
starrylight99 70a37ae
A-Assertions
starrylight99 191b988
Merge pull request #2 from starrylight99/branch-A-Assertions
starrylight99 5635950
save
starrylight99 d5d469d
A-CodeQuality
starrylight99 be0054b
A-CodeQuality
starrylight99 6d33c7c
Merge pull request #3 from starrylight99/branch-A-CodeQuality
starrylight99 3cb34ca
Refactored Session.java: Segmented initializeUI
starrylight99 598ab02
Merge pull request #4 from starrylight99/A-FullCommitMessage
starrylight99 999e1fb
BCD-Extension
starrylight99 724ec38
BCD-Extension
starrylight99 f00ce7a
Merge branch 'master' into branch-BCD-Extension
starrylight99 6d7c0e0
Merge pull request #5 from starrylight99/branch-BCD-Extension
starrylight99 f635ed8
A-Release
starrylight99 93693a1
Merge pull request #6 from starrylight99/branch-A-Release
starrylight99 e3abefc
A-UserGuide
starrylight99 31d7187
A-UserGuide
starrylight99 fafd23e
Ui.png
starrylight99 72a70f3
Fixed Ui.png name
starrylight99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package duke.Utils; | ||
|
||
/** | ||
* The OutOfRangeException class represents an exception that is thrown when | ||
* a user provides an input number that is out of range of the current tasks. | ||
*/ | ||
public class OutOfRangeException extends DukeException { | ||
/** | ||
* Constructs a new OutOfRangeException with a default error message. | ||
*/ | ||
protected OutOfRangeException() { | ||
super("I'm sorry, but your input number is out of range of the current tasks"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ enum Type { | |
DEADLINE("deadline"), | ||
EVENT("event"), | ||
DELETE("delete"), | ||
FIND("find"), | ||
NOTFOUND(""); | ||
|
||
private final String name; | ||
|
@@ -102,6 +103,8 @@ protected Response execute(String input, String command) throws DukeException { | |
return this.delete(Command.assertInteger(input, command)); | ||
case LIST: | ||
return this.list(); | ||
case FIND: | ||
return this.find(Command.assertString(input, command)); | ||
default: | ||
throw new CommandNotFoundException(); | ||
} | ||
|
@@ -151,7 +154,7 @@ private boolean inRange(int idx) { | |
protected Response mark(int idx) throws DukeException { | ||
ArrayList<String> output = new ArrayList<>(); | ||
if (!this.inRange(idx)) { | ||
throw new TaskNotFoundException(); | ||
throw new OutOfRangeException(); | ||
} | ||
Task task = this.tasks.get(--idx); | ||
task.mark(); | ||
|
@@ -171,7 +174,7 @@ protected Response mark(int idx) throws DukeException { | |
protected Response unmark(int idx) throws DukeException { | ||
ArrayList<String> output = new ArrayList<>(); | ||
if (!this.inRange(idx)) { | ||
throw new TaskNotFoundException(); | ||
throw new OutOfRangeException(); | ||
} | ||
Task task = this.tasks.get(--idx); | ||
task.unmark(); | ||
|
@@ -191,7 +194,7 @@ protected Response unmark(int idx) throws DukeException { | |
protected Response delete(int idx) throws DukeException { | ||
ArrayList<String> output = new ArrayList<>(); | ||
if (!this.inRange(idx)) { | ||
throw new TaskNotFoundException(); | ||
throw new OutOfRangeException(); | ||
} | ||
Task task = this.tasks.get(--idx); | ||
output.add("Noted. I've removed this task:"); | ||
|
@@ -201,4 +204,20 @@ protected Response delete(int idx) throws DukeException { | |
|
||
return Response.generate(output); | ||
} | ||
|
||
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); | ||
} | ||
Comment on lines
+219
to
+233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very short and clear code! |
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!