From 3f26e76d5cc5e58de9a236cc5cb473c579d63a4b Mon Sep 17 00:00:00 2001 From: Gregor Riegler Date: Mon, 27 May 2013 17:24:15 +0200 Subject: [PATCH] Create Driver and DriverXVSM classes for XVSM --- .../tuwien/sbc/valesriegler/common/Util.java | 15 ++++++++ .../sbc/valesriegler/xvsm/DriverXVSM.java | 18 ++++++++++ .../sbc/valesriegler/xvsm/driver/Driver.java | 34 +++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java create mode 100644 src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/driver/Driver.java diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java index c4fb3a4..78939f5 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java @@ -69,4 +69,19 @@ public abstract class Util { return random.nextInt(max - min + 1) + min; } + public static int parseId(String[] args, String usage) { + if (args.length != 1) { + throw new IllegalArgumentException(usage); + } + + int parsedId = 0; + try { + parsedId = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + throw new IllegalArgumentException(usage); + } + + return parsedId; + } + } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java new file mode 100644 index 0000000..5e954f2 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java @@ -0,0 +1,18 @@ +package at.ac.tuwien.sbc.valesriegler.xvsm; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DriverXVSM extends AbstractXVSMConnector { + private static final Logger log = LoggerFactory.getLogger(DriverXVSM.class); + + private int driverId; + + public DriverXVSM(int id) { + super(); + + this.driverId = id; + + } +} diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/driver/Driver.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/driver/Driver.java new file mode 100644 index 0000000..ba14e48 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/driver/Driver.java @@ -0,0 +1,34 @@ +package at.ac.tuwien.sbc.valesriegler.xvsm.driver; + +import at.ac.tuwien.sbc.valesriegler.common.Util; +import at.ac.tuwien.sbc.valesriegler.xvsm.CookXVSM; +import at.ac.tuwien.sbc.valesriegler.xvsm.DriverXVSM; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Driver { + private static final String USAGE = "Driver needs exactly one parameter: ID of type Integer"; + private static final Logger log = LoggerFactory.getLogger(Driver.class); + + private int id; + private DriverXVSM xvsm; + + public static void main(String[] args) { + final int parsedId = Util.parseId(args, USAGE); + + Driver cook = new Driver(parsedId); + cook.start(); + } + + + private void start() { + xvsm = new DriverXVSM(id); + + } + + public Driver(int id) { + this.id = id; + log.info("I AM A Driver WITH ID {}", id); + } + +} -- 2.43.0