forked from nus-cs2113-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from EugeneChanJiajun/master
Add parser and exceptions
- Loading branch information
Showing
8 changed files
with
114 additions
and
44 deletions.
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!"); | ||
} | ||
} | ||
} |
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