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 #121 from daryltay415/master
Add packages
- Loading branch information
Showing
13 changed files
with
670 additions
and
627 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
147 changes: 74 additions & 73 deletions
147
...main/java/seedu/duke/CheckParameters.java → ...travel/errorhandlers/CheckParameters.java
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,73 +1,74 @@ | ||
package seedu.duke; | ||
|
||
import java.io.IOException; | ||
import java.time.DateTimeException; | ||
import java.util.NoSuchElementException; | ||
|
||
import static seedu.duke.Parser.isNumeric; | ||
|
||
public class CheckParameters { | ||
|
||
/** | ||
* Checks for all possible input errors that users may make and throws the corresponding exceptions | ||
* | ||
* @param input Input array that users placed into the chatbot | ||
* @throws OmniException when any of the corresponding input format is wrong | ||
*/ | ||
public static void addExceptions(String[] input) throws OmniException{ | ||
if (input.length >= 4 && input[1].isBlank()) { | ||
throw new OmniException("The description cannot be empty!"); | ||
} else if (input.length >= 4 && input[2].isBlank()) { | ||
throw new OmniException("The date cannot be empty!"); | ||
} else if (input.length >= 4 && input[3].isBlank()) { | ||
throw new OmniException("The duration cannot be empty!"); | ||
} else if (input.length >= 5 && input[4].isBlank()) { | ||
throw new OmniException("The tag cannot be empty!"); | ||
} else if (input.length < 4 || input[3].contains("/tag")){ | ||
throw new OmniException("Please check that your add command is in this format: add DESCRIPTION " + | ||
"/date YYYY-MM-DD /duration DURATION" | ||
+ " or add DESCRIPTION /date YYYY-MM-DD /duration DURATION /tag TAG"); | ||
} | ||
} | ||
|
||
/** | ||
* Checks for all possible input errors that users may make when updating and throws the corresponding exceptions | ||
* | ||
* @param command Command array that users placed into the chatbot | ||
* @throws OmniException when any of the corresponding input format is wrong | ||
*/ | ||
public static void updateExceptions(String[] command) throws OmniException { | ||
if (command.length >= 4 && (command[1].isBlank() || !isNumeric(command[1]))) { | ||
throw new OmniException("The update index cannot be empty or non numerical!"); | ||
} else if (command.length >= 4 && command[2].isBlank()) { | ||
throw new OmniException("The date cannot be empty!"); | ||
} else if (command.length >= 4 && command[3].isBlank()) { | ||
throw new OmniException("The duration cannot be empty!"); | ||
} else if(command.length >= 5 && command[4].isBlank()){ | ||
throw new OmniException("The tag cannot be empty!"); | ||
} else if (command.length >= 4 && !command[3].contains("/tag")) { | ||
throw new OmniException("Please check that your update command is in this format: update INDEX " + | ||
"/date YYYY-MM-DD /duration DURATION" | ||
+ " or update INDEX /date YYYY-MM-DD /duration DURATION /tag TAG"); | ||
} | ||
} | ||
|
||
/** | ||
* Checks for all format errors in the user input and throes the correct exceptions | ||
* | ||
* @param exception Exception thrown | ||
*/ | ||
public static void handleException(Exception exception) { | ||
if (exception instanceof OmniException) { | ||
Ui.printException((OmniException) exception); | ||
} else if (exception instanceof NoSuchElementException) { | ||
Ui.printNoSuchElementException((NoSuchElementException) exception); | ||
} else if (exception instanceof NumberFormatException) { | ||
Ui.printNumberTooLargeException((NumberFormatException) exception); | ||
} else if (exception instanceof DateTimeException) { | ||
Ui.printDateTimeExceptionError(); | ||
} else if (exception instanceof IOException) { | ||
Ui.printSavingError(); | ||
} | ||
} | ||
} | ||
package seedu.omnitravel.errorhandlers; | ||
|
||
import seedu.omnitravel.ui.Ui; | ||
|
||
import java.io.IOException; | ||
import java.time.DateTimeException; | ||
import java.util.NoSuchElementException; | ||
|
||
import static seedu.omnitravel.parser.Parser.isNumeric; | ||
|
||
public class CheckParameters { | ||
|
||
/** | ||
* Checks for all possible input errors that users may make and throws the corresponding exceptions | ||
* @param input Input array that users placed into the chatbot | ||
* @throws OmniException when any of the corresponding input format is wrong | ||
*/ | ||
public static void addExceptions(String[] input) throws OmniException{ | ||
if (input.length >= 4 && input[1].isBlank()) { | ||
throw new OmniException("The description cannot be empty!"); | ||
} else if (input.length >= 4 && input[2].isBlank()) { | ||
throw new OmniException("The date cannot be empty!"); | ||
} else if (input.length >= 4 && input[3].isBlank()) { | ||
throw new OmniException("The duration cannot be empty!"); | ||
} else if (input.length >= 5 && input[4].isBlank()) { | ||
throw new OmniException("The tag cannot be empty!"); | ||
} else if (input.length < 4 || input[3].contains("/tag")){ | ||
throw new OmniException("Please check that your add command is in this format: add DESCRIPTION " + | ||
"/date YYYY-MM-DD /duration DURATION" | ||
+ " or add DESCRIPTION /date YYYY-MM-DD /duration DURATION /tag TAG"); | ||
} | ||
} | ||
|
||
/** | ||
* Checks for all possible input errors that users may make when updating and throws the corresponding exceptions | ||
* | ||
* @param command Command array that users placed into the chatbot | ||
* @throws OmniException when any of the corresponding input format is wrong | ||
*/ | ||
public static void updateExceptions(String[] command) throws OmniException { | ||
if (command.length >= 4 && (command[1].isBlank() || !isNumeric(command[1]))) { | ||
throw new OmniException("The update index cannot be empty or non numerical!"); | ||
} else if (command.length >= 4 && command[2].isBlank()) { | ||
throw new OmniException("The date cannot be empty!"); | ||
} else if (command.length >= 4 && command[3].isBlank()) { | ||
throw new OmniException("The duration cannot be empty!"); | ||
} else if(command.length >= 5 && command[4].isBlank()){ | ||
throw new OmniException("The tag cannot be empty!"); | ||
} else if (command.length >= 4 && !command[3].contains("/tag")) { | ||
throw new OmniException("Please check that your update command is in this format: update INDEX " + | ||
"/date YYYY-MM-DD /duration DURATION" | ||
+ " or update INDEX /date YYYY-MM-DD /duration DURATION /tag TAG"); | ||
} | ||
} | ||
|
||
/** | ||
* Checks for all format errors in the user input and throes the correct exceptions | ||
* | ||
* @param exception Exception thrown | ||
*/ | ||
public static void handleException(Exception exception) { | ||
if (exception instanceof OmniException) { | ||
Ui.printException((OmniException) exception); | ||
} else if (exception instanceof NoSuchElementException) { | ||
Ui.printNoSuchElementException((NoSuchElementException) exception); | ||
} else if (exception instanceof NumberFormatException) { | ||
Ui.printNumberTooLargeException((NumberFormatException) exception); | ||
} else if (exception instanceof DateTimeException) { | ||
Ui.printDateTimeExceptionError(); | ||
} else if (exception instanceof IOException) { | ||
Ui.printSavingError(); | ||
} | ||
} | ||
} |
14 changes: 7 additions & 7 deletions
14
src/main/java/seedu/duke/OmniException.java → ...nitravel/errorhandlers/OmniException.java
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,7 +1,7 @@ | ||
package seedu.duke; | ||
|
||
public class OmniException extends Exception { | ||
public OmniException(String errorMessage){ | ||
super(errorMessage); | ||
} | ||
} | ||
package seedu.omnitravel.errorhandlers; | ||
|
||
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
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
8 changes: 7 additions & 1 deletion
8
src/main/java/seedu/duke/FileSave.java → ...va/seedu/omnitravel/storage/FileSave.java
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
36 changes: 18 additions & 18 deletions
36
src/main/java/seedu/duke/Accommodation.java → ...el/travelactivitytypes/Accommodation.java
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,18 +1,18 @@ | ||
package seedu.duke; | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Accommodation extends TravelActivity { | ||
private LocalDate date; | ||
private String duration; | ||
|
||
public Accommodation(String line, LocalDate date, String duration, String tag, String expense){ | ||
super(line, date, duration, tag, expense); | ||
} | ||
|
||
@Override | ||
public String toString(){ | ||
return "Accommodation: " + super.toString(); | ||
} | ||
|
||
} | ||
package seedu.omnitravel.travelactivitytypes; | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Accommodation extends TravelActivity { | ||
private LocalDate date; | ||
private String duration; | ||
|
||
public Accommodation(String line, LocalDate date, String duration, String tag, String expense){ | ||
super(line, date, duration, tag, expense); | ||
} | ||
|
||
@Override | ||
public String toString(){ | ||
return "Accommodation: " + super.toString(); | ||
} | ||
|
||
} |
28 changes: 14 additions & 14 deletions
28
src/main/java/seedu/duke/Food.java → .../omnitravel/travelactivitytypes/Food.java
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,14 +1,14 @@ | ||
package seedu.duke; | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Food extends TravelActivity { | ||
public Food(String line, LocalDate date, String duration, String tag, String expense){ | ||
super(line, date, duration, tag, expense); | ||
} | ||
|
||
@Override | ||
public String toString(){ | ||
return "Food: " + super.toString(); | ||
} | ||
} | ||
package seedu.omnitravel.travelactivitytypes; | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Food extends TravelActivity { | ||
public Food(String line, LocalDate date, String duration, String tag, String expense){ | ||
super(line, date, duration, tag, expense); | ||
} | ||
|
||
@Override | ||
public String toString(){ | ||
return "Food: " + super.toString(); | ||
} | ||
} |
26 changes: 13 additions & 13 deletions
26
src/main/java/seedu/duke/Landmark.java → ...itravel/travelactivitytypes/Landmark.java
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,13 +1,13 @@ | ||
package seedu.duke; | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Landmark extends TravelActivity { | ||
public Landmark(String line, LocalDate date, String duration, String tag, String expense){ | ||
super(line, date, duration, tag, expense); | ||
} | ||
@Override | ||
public String toString(){ | ||
return "Landmark: " + super.toString(); | ||
} | ||
} | ||
package seedu.omnitravel.travelactivitytypes; | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Landmark extends TravelActivity { | ||
public Landmark(String line, LocalDate date, String duration, String tag, String expense){ | ||
super(line, date, duration, tag, expense); | ||
} | ||
@Override | ||
public String toString(){ | ||
return "Landmark: " + super.toString(); | ||
} | ||
} |
Oops, something went wrong.