diff --git a/src/main/java/seedu/omnitravel/parser/Parser.java b/src/main/java/seedu/omnitravel/parser/Parser.java index f9e22ed03b..1f85c40dc4 100644 --- a/src/main/java/seedu/omnitravel/parser/Parser.java +++ b/src/main/java/seedu/omnitravel/parser/Parser.java @@ -12,8 +12,6 @@ import java.time.LocalDate; import java.util.logging.Logger; -import static seedu.omnitravel.errorhandlers.CheckParameters.isNumeric; - public class Parser { private static Logger logger = Logger.getLogger("ParserLogger"); @@ -151,7 +149,7 @@ public static void addCommand(String line, TravelActivityList list) throws OmniE * @throws OmniException if command.length != 2 && command[1] is not numeric */ public static void deleteCommand(String[] command, TravelActivityList list) throws OmniException { - if (command.length == 2 && isNumeric(command[1])){ + if (command.length == 2 && CheckParameters.isNumeric(command[1])){ int listNumber = Integer.parseInt(command[1]); list.removeTravelActivity(listNumber); } else { @@ -167,7 +165,7 @@ public static void deleteCommand(String[] command, TravelActivityList list) thro * @throws OmniException if command.length != 2 && command[1] is not numeric */ public static void checkCommand(String[] command, TravelActivityList list) throws OmniException { - if (command.length == 2 && isNumeric(command[1])){ + if (command.length == 2 && CheckParameters.isNumeric(command[1])){ int listNumber = Integer.parseInt(command[1]); list.checkTravelActivity(listNumber); } else { @@ -183,7 +181,7 @@ public static void checkCommand(String[] command, TravelActivityList list) throw * @throws OmniException if command.length != 2 && command[1] is not numeric */ public static void uncheckCommand(String[] command, TravelActivityList list) throws OmniException { - if (command.length == 2 && isNumeric(command[1])){ + if (command.length == 2 && CheckParameters.isNumeric(command[1])){ int listNumber = Integer.parseInt(command[1]); list.uncheckTravelActivity(listNumber); @@ -202,7 +200,7 @@ public static void uncheckCommand(String[] command, TravelActivityList list) thr */ public static void tagCommand(String line, TravelActivityList list) throws OmniException { String[] command = line.split(" "); - if (command.length >= 3 && isNumeric(command[1])){ + if (command.length >= 3 && CheckParameters.isNumeric(command[1])){ String index = command[1]; String[] tagSplit = line.split(index); String tag = tagSplit[1].trim(); @@ -223,7 +221,7 @@ public static void tagCommand(String line, TravelActivityList list) throws OmniE * @throws OmniException if command.length != 2 && command[1] is not numeric */ public static void removeTagCommand(String[] command, TravelActivityList list) throws OmniException { - if (command.length == 2 && isNumeric(command[1])) { + if (command.length == 2 && CheckParameters.isNumeric(command[1])) { int listNumber = Integer.parseInt(command[1]); list.removeTag(listNumber); } else { @@ -308,7 +306,7 @@ public static void findCommand(String line, TravelActivityList list) throws Omni */ public static void expenseCommand(String line, TravelActivityList list) throws OmniException { String[] command = line.split(" "); - if (command.length == 3 && isNumeric(command[1])){ + if (command.length == 3 && CheckParameters.isNumeric(command[1])){ int listNumber = Integer.parseInt(command[1]); String expense = command[2]; list.expenseActivity(listNumber, expense); @@ -327,7 +325,7 @@ public static void expenseCommand(String line, TravelActivityList list) throws O * @throws OmniException if command.length != 2 && command[1] is not numeric */ public static void removeExpenseCommand(String[] command, TravelActivityList list) throws OmniException { - if (command.length == 2 && isNumeric(command[1])) { + if (command.length == 2 && CheckParameters.isNumeric(command[1])) { int listNumber = Integer.parseInt(command[1]); list.removeExpense(listNumber); } else { @@ -369,7 +367,7 @@ public static void totalExpenseCommand(String line, TravelActivityList list) thr */ public static void locationCommand(String line, TravelActivityList list) throws OmniException { String[] command = line.split(" "); - if (command.length >= 3 && isNumeric(command[1])){ + if (command.length >= 3 && CheckParameters.isNumeric(command[1])){ String index = command[1]; String[] locationSplit = line.split(index); String location = locationSplit[1].trim(); @@ -390,7 +388,7 @@ public static void locationCommand(String line, TravelActivityList list) throws * @throws OmniException if command.length != 2 && command[1] is not numeric */ public static void removeLocationCommand(String[] command, TravelActivityList list) throws OmniException { - if (command.length == 2 && isNumeric(command[1])) { + if (command.length == 2 && CheckParameters.isNumeric(command[1])) { int listNumber = Integer.parseInt(command[1]); list.removeLocation(listNumber); } else { diff --git a/src/test/java/seedu/omnitravel/OmniTravelTest.java b/src/test/java/seedu/omnitravel/OmniTravelTest.java index 8a5aae5db1..2e37fdf5f1 100644 --- a/src/test/java/seedu/omnitravel/OmniTravelTest.java +++ b/src/test/java/seedu/omnitravel/OmniTravelTest.java @@ -378,13 +378,13 @@ public void testListTags() throws OmniException { // Testcases without tags list.addTravelActivity(new Accommodation("Airbnb", - LocalDate.parse("2012-12-12"), "2hours", "", "")); + LocalDate.parse("2012-12-12"), "2hours", "", "", "")); list.addTravelActivity(new Food("Takoyaki", - LocalDate.parse("2012-12-12"), "2hours", "", "")); + LocalDate.parse("2012-12-12"), "2hours", "", "", "")); list.addTravelActivity(new Landmark("Pyramid", - LocalDate.parse("2012-12-12"), "2hours", "", "")); + LocalDate.parse("2012-12-12"), "2hours", "", "", "")); list.addTravelActivity(new TravelActivity("Go home", - LocalDate.parse("2012-12-12"), "2hours", "", "")); + LocalDate.parse("2012-12-12"), "2hours", "", "", "")); list.listTags(); String expectedOutput = "1. campus stay" + System.lineSeparator()