forked from nus-cs2113-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add parser and exceptions #33
Merged
EugeneChanJiajun
merged 4 commits into
AY2324S2-CS2113-T12-4:master
from
EugeneChanJiajun:master
Mar 17, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,7 @@ | ||
package seedu.duke; | ||
|
||
public class OmniException extends Exception { | ||
public OmniException(String errorMessage){ | ||
super(errorMessage); | ||
} | ||
} |
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,37 @@ | ||
package seedu.duke; | ||
|
||
public class Parser { | ||
public static void getList(TravelActivityList list){ | ||
System.out.println("Here are the travel activities in your list:"); | ||
list.listTravelActivities(); | ||
} | ||
|
||
public static void addCommand(String line, String[] command, TravelActivityList list) throws OmniException{ | ||
if (command.length >= 2) { | ||
TravelActivity newActivity = new TravelActivity(line.substring(4)); | ||
list.addTravelActivity(newActivity); | ||
System.out.println("I added a new travel activity"); | ||
System.out.println(newActivity); | ||
} else { | ||
throw new OmniException("The description of add cannot be empty!"); | ||
} | ||
} | ||
|
||
public static void deleteCommand(String[] command, TravelActivityList list) throws OmniException { | ||
if (command.length == 2){ | ||
int listNumber = Integer.parseInt(command[1]); | ||
list.removeTravelActivity(listNumber); | ||
} else { | ||
throw new OmniException("Please specify which task to delete"); | ||
} | ||
} | ||
|
||
public static void findCommand(String[] command, TravelActivityList list) throws OmniException{ | ||
if (command.length == 2) { | ||
String keyword = command[1]; | ||
list.searchKeyword(keyword); | ||
} else { | ||
throw new OmniException("Please specify which keyword you want to find!"); | ||
} | ||
} | ||
} | ||
Comment on lines
+1
to
+37
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. LGTM |
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
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
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
Hello from | ||
____ _ | ||
| _ \ _ _| | _____ | ||
| | | | | | | |/ / _ \ | ||
| |_| | |_| | < __/ | ||
|____/ \__,_|_|\_\___| | ||
|
||
What is your name? | ||
Hello James Gosling | ||
____________________________________________________________ | ||
____ _ _ _ _____ ____ ____ _ _____ _ | ||
/ _ \/ \__/|/ \ /|/ \/__ __\/ __\/ _ \/ \ |\/ __// \ | ||
| / \|| |\/||| |\ ||| | / \ | \/|| / \|| | //| \ | | | ||
| \_/|| | ||| | \||| | | | | /| |-||| \// | /_ | |_/\ | ||
\____/\_/ \|\_/ \|\_/ \_/ \_/\_\\_/ \|\__/ \____\\____/) | ||
Hello | ||
How may I assist you? | ||
____________________________________________________________ |
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 |
---|---|---|
@@ -1 +0,0 @@ | ||
James Gosling | ||
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
Oops, something went wrong.
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.
Nice catching of exceptions