From 8407b8a66054ec2438e878de8421dcdceadf4b5c Mon Sep 17 00:00:00 2001 From: jing-xuan Date: Tue, 12 Nov 2019 01:08:31 +0800 Subject: [PATCH] fixed minor bugs --- src/main/java/logic/Parser.java | 9 ++++++++- .../java/logic/usercode/actions/GotoMarketAction.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/logic/Parser.java b/src/main/java/logic/Parser.java index e4167e626d..c42fef6a9c 100644 --- a/src/main/java/logic/Parser.java +++ b/src/main/java/logic/Parser.java @@ -232,7 +232,14 @@ private static Command parseTaskLog(String userInput) throws FarmioException { return new CommandLog(pageNumber); } LOGGER.log(Level.INFO, "Detected invalid command for command: " + userInput); - throw new FarmioException("Invalid Log Page \nPlease enter log PAGE_NUMBER."); + try { + if (!userInput.substring(0, userInput.indexOf(" ")).equals("log")) { + throw new FarmioException("Invalid command!"); + } + } catch (IndexOutOfBoundsException e) { + throw new FarmioException("Invalid command!"); + } + throw new FarmioException("Invalid Log Page! Please enter log PAGE_NUMBER"); } /** diff --git a/src/main/java/logic/usercode/actions/GotoMarketAction.java b/src/main/java/logic/usercode/actions/GotoMarketAction.java index 69b8724dbc..1a7ff5d40b 100644 --- a/src/main/java/logic/usercode/actions/GotoMarketAction.java +++ b/src/main/java/logic/usercode/actions/GotoMarketAction.java @@ -14,7 +14,7 @@ public GotoMarketAction() { @Override public void execute(Frontend frontend, Storage storage, Farmer farmer) throws FarmioFatalException { if (farmer.getLocation().equals("Market")) { - frontend.simulate("GotoMarketSimulation", 12); + frontend.simulate("GotoMarketSimulation", 1); frontend.typeWriter("You are already at the market", false); } else { farmer.changeLocation("Traveling");