From 0ff7d6e300fe9c6b305d07e1188f5383185245e6 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Wed, 19 Feb 2020 08:57:18 +0100 Subject: [PATCH] Remove not needed pattern --- src/edu/kit/informatik/ui/command/CommandFactory.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/edu/kit/informatik/ui/command/CommandFactory.java b/src/edu/kit/informatik/ui/command/CommandFactory.java index d77193a..7cb674c 100644 --- a/src/edu/kit/informatik/ui/command/CommandFactory.java +++ b/src/edu/kit/informatik/ui/command/CommandFactory.java @@ -57,7 +57,6 @@ public final class CommandFactory { private static final Pattern PUT_TRAIN_ARGUMENTS = Pattern.compile(" (" + NUMBER + ") at \\((" + VECTOR + ")\\) in direction (" + VECTOR + ")"); private static final String STEP = "step"; - private static final String POSITIVE_NUMBER = " \\+?\\d+"; /** * Parse a single line of user input into one command. @@ -87,7 +86,7 @@ public final class CommandFactory { return new AddSwitch(start, end1, end2); } else if (command.startsWith(DELETE_TRACK)) { String argument = command.substring(DELETE_TRACK.length()); - if (!argument.matches(POSITIVE_NUMBER)) { + if (!argument.matches(" " + NUMBER)) { throw new InvalidInputException("invalid/missing delete track argument"); } int id = Integer.parseInt(argument.substring(1)); @@ -182,7 +181,7 @@ public final class CommandFactory { return new AddTrain(trainId, rollingStockId); } else if (command.startsWith(DELETE_TRAIN)) { String argument = command.substring(DELETE_TRAIN.length()); - if (!argument.matches(POSITIVE_NUMBER)) { + if (!argument.matches(" " + NUMBER)) { throw new InvalidInputException("invalid delete train argument"); } int id = Integer.parseInt(argument.substring(1)); @@ -194,7 +193,7 @@ public final class CommandFactory { return new ListTrains(); } else if (command.startsWith(SHOW_TRAIN)) { String argument = command.substring(SHOW_TRAIN.length()); - if (!argument.matches(POSITIVE_NUMBER)) { + if (!argument.matches(" " + NUMBER)) { throw new InvalidInputException("invalid show train argument"); } int id = Integer.parseInt(argument.substring(1));