From 8a51d8ea974ecf6443635814216cdbfd2d78ba0d Mon Sep 17 00:00:00 2001 From: ChenKangg Date: Sun, 7 Apr 2024 15:10:30 +0800 Subject: [PATCH] fix conflicts --- .../java/seedu/omnitravel/parser/Parser.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/seedu/omnitravel/parser/Parser.java b/src/main/java/seedu/omnitravel/parser/Parser.java index 2c43a6c442..f9e22ed03b 100644 --- a/src/main/java/seedu/omnitravel/parser/Parser.java +++ b/src/main/java/seedu/omnitravel/parser/Parser.java @@ -12,6 +12,8 @@ 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"); @@ -81,7 +83,7 @@ public static void activityCommand(String line, TravelActivityList list) throws System.out.println("I added a new accommodation"); break; case "food": - activity = new Food(description, date, duration, tag, ""); + activity = new Food(description, date, duration, tag, location, ""); System.out.println("I added a new food activity"); break; case "landmark": @@ -110,8 +112,8 @@ public static void activityCommand(String line, TravelActivityList list) throws public static void addCommand(String line, TravelActivityList list) throws OmniException{ Ui.printLine(); String[] command = line.split("add | /date | /duration | /tag | /location"); - logger.log(Level.INFO, command[0] + " // " + command[1]); - CheckParameters.addExceptions(command); + //logger.log(Level.INFO, command[0] + " // " + command[1]); + CheckParameters.addExceptions(command, "add", line); String description = command[1].trim(); LocalDate date = LocalDate.parse(command[2]); String duration = command[3].trim(); @@ -149,7 +151,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 && CheckParameters.isNumeric(command[1])){ + if (command.length == 2 && isNumeric(command[1])){ int listNumber = Integer.parseInt(command[1]); list.removeTravelActivity(listNumber); } else { @@ -165,7 +167,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 && CheckParameters.isNumeric(command[1])){ + if (command.length == 2 && isNumeric(command[1])){ int listNumber = Integer.parseInt(command[1]); list.checkTravelActivity(listNumber); } else { @@ -181,7 +183,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 && CheckParameters.isNumeric(command[1])){ + if (command.length == 2 && isNumeric(command[1])){ int listNumber = Integer.parseInt(command[1]); list.uncheckTravelActivity(listNumber); @@ -200,7 +202,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 && CheckParameters.isNumeric(command[1])){ + if (command.length >= 3 && isNumeric(command[1])){ String index = command[1]; String[] tagSplit = line.split(index); String tag = tagSplit[1].trim(); @@ -221,7 +223,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 && CheckParameters.isNumeric(command[1])) { + if (command.length == 2 && isNumeric(command[1])) { int listNumber = Integer.parseInt(command[1]); list.removeTag(listNumber); } else { @@ -306,7 +308,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 && CheckParameters.isNumeric(command[1])){ + if (command.length == 3 && isNumeric(command[1])){ int listNumber = Integer.parseInt(command[1]); String expense = command[2]; list.expenseActivity(listNumber, expense); @@ -325,7 +327,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 && CheckParameters.isNumeric(command[1])) { + if (command.length == 2 && isNumeric(command[1])) { int listNumber = Integer.parseInt(command[1]); list.removeExpense(listNumber); } else { @@ -410,7 +412,9 @@ public static void findLocationCommand(String line, TravelActivityList list) thr } else { list.findLocation(command[1].trim()); } - /** + } + + /** * Handles the case whereby the command is listtags * @param command The command given by the user * @param list The travel activity list