diff options
| author | Camil Staps | 2015-05-29 13:17:53 +0200 | 
|---|---|---|
| committer | Camil Staps | 2015-05-29 13:17:53 +0200 | 
| commit | 3ccaa674fdbd3408d4cbea3ed9abb02c14433b9c (patch) | |
| tree | c51dbe974566b4c437500fbf6894b626b203d265 /Week14 Route 66 | |
| parent | Hack to make it seem to be working (diff) | |
licensing; reorganisation; javadoc; cleanup
Diffstat (limited to 'Week14 Route 66')
13 files changed, 315 insertions, 203 deletions
| diff --git a/Week14 Route 66/nbproject/project.properties b/Week14 Route 66/nbproject/project.properties index 93592ec..63a2ce2 100644 --- a/Week14 Route 66/nbproject/project.properties +++ b/Week14 Route 66/nbproject/project.properties @@ -55,7 +55,7 @@ javadoc.splitindex=true  javadoc.use=true  javadoc.version=false  javadoc.windowtitle= -main.class=OO14route66.Route66 +main.class=com.camilstaps.route66.Route66  manifest.file=manifest.mf  meta.inf.dir=${src.dir}/META-INF  mkdist.disabled=false diff --git a/Week14 Route 66/src/OO14route66/Controller.java b/Week14 Route 66/src/OO14route66/Controller.java deleted file mode 100644 index 83e6098..0000000 --- a/Week14 Route 66/src/OO14route66/Controller.java +++ /dev/null @@ -1,72 +0,0 @@ -package OO14route66; - -import com.camilstaps.route66.Driver; -import java.util.Random; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * Route66 Controller - * @author Pieter Koopman, Camil Staps - * - * The initial controller runs as a single thread - */ -public class Controller { -    private int delay = 120;                // average sleep time -    private final Model model;              // the model -    private final Random random;            // a random generator - -    /** -     * The constructor of the controller -     * @param model holds the cars -     */ -    public Controller(Model model) { -        this.model  = model; -        random      = new Random(); -    } - -    /** -     * Tell the drivers of all cars in the model to start driving -     */ -    public void run() { -        ExecutorService service = Executors.newCachedThreadPool(); -        for (Car car : model.getCars()) { -            Driver d = car.getDriver(); -            d.setDelay(delay); -            service.execute(d); -        } -    } -     -    /** -     * stop all cars by setting boolean run to false -     */ -    public void stopCars() { -        for (Car car : model.getCars()) { -            car.getDriver().setRunning(false); -        } -    } - -    /** -     * start all cars by setting boolean run to true -     */ -    public void resumeCars() { -        for (Car car : model.getCars()) { -            car.getDriver().setRunning(true); -        } -    } -     -    public int getDelay() { -        return delay; -    } -     -    /** -     * set delay between maximum and minimum bounds -     * @param d  -     */ -    public void setDelay(int d) { -        delay = Math.max(20, Math.min (2000, d)); -        for (Car car : model.getCars()) { -            car.getDriver().setDelay(delay); -        } -    } -} diff --git a/Week14 Route 66/src/OO14route66/Car.java b/Week14 Route 66/src/com/camilstaps/route66/Car.java index c12291a..b118a3c 100644 --- a/Week14 Route 66/src/OO14route66/Car.java +++ b/Week14 Route 66/src/com/camilstaps/route66/Car.java @@ -1,6 +1,28 @@ -package OO14route66; +/* + * The MIT License (MIT) + *  + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + *  + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + *  + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + *  + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.camilstaps.route66; -import com.camilstaps.route66.Driver;  import java.awt.Color;  import java.awt.Graphics;  import java.util.Random; @@ -34,7 +56,6 @@ public class Car {       *  - choose a random speed       *  - set right location, direction and colour       *  - create new Driver object -     *  - say hello to the Overviewer       *        * @param number of the car       * @param model the model the car is in @@ -46,8 +67,8 @@ public class Car {          direction = Direction.intToDirection(number);          location = RoadView.WINDOWSIZE - 2 - (number/Model.DIRECTIONS) * (CARLENGTH + MINCARSPACE);          colour = carColours[number % carColours.length]; -        driver = new Driver(this, model);          this.model = model; +        driver = new Driver(this, model);      }      /** @@ -99,10 +120,19 @@ public class Car {          model.update();      } +    /** +     * Is the car in front of the crossing? That is, is the car now not on the +     * crossing but would it be there after the next step? +     * @return  +     */      public boolean isInFrontOfCrossing() {          return location < RoadView.getStartCrossing() && getNewLocation() >= RoadView.getStartCrossing();      } +    /** +     * Is the car on the crossing? +     * @return  +     */      public boolean isOnCrossing() {          return location > RoadView.getStartCrossing() && location - CARLENGTH < RoadView.getEndCrossing();      } diff --git a/Week14 Route 66/src/com/camilstaps/route66/Controller.java b/Week14 Route 66/src/com/camilstaps/route66/Controller.java new file mode 100644 index 0000000..e0eff83 --- /dev/null +++ b/Week14 Route 66/src/com/camilstaps/route66/Controller.java @@ -0,0 +1,95 @@ +/* + * The MIT License (MIT) + *  + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + *  + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + *  + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + *  + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.camilstaps.route66; + +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * Route66 Controller + *  + * Use different threads for every driver + *  + * @author Pieter Koopman, Camil Staps + */ +public class Controller { +    private int delay = 120;                // average sleep time +    private final Model model;              // the model +    private final Random random;            // a random generator + +    /** +     * The constructor of the controller +     * @param model holds the cars +     */ +    public Controller(Model model) { +        this.model  = model; +        random      = new Random(); +    } + +    /** +     * Tell the drivers of all cars in the model to start driving +     */ +    public void run() { +        ExecutorService service = Executors.newCachedThreadPool(); +        for (Car car : model.getCars()) { +            Driver d = car.getDriver(); +            d.setDelay(delay); +            service.execute(d); +        } +    } +     +    /** +     * Stop all cars +     */ +    public void stopCars() { +        for (Car car : model.getCars()) { +            car.getDriver().stopRunning(); +        } +    } + +    /** +     * Resume all cars +     */ +    public void resumeCars() { +        for (Car car : model.getCars()) { +            car.getDriver().resumeRunning(); +        } +    } +     +    public int getDelay() { +        return delay; +    } +     +    /** +     * Set delay between maximum and minimum bounds +     * @param d  +     */ +    public void setDelay(int d) { +        delay = Math.max(20, Math.min (2000, d)); +        for (Car car : model.getCars()) { +            car.getDriver().setDelay(delay); +        } +    } +} diff --git a/Week14 Route 66/src/com/camilstaps/route66/Crossing.java b/Week14 Route 66/src/com/camilstaps/route66/Crossing.java deleted file mode 100644 index 65e2527..0000000 --- a/Week14 Route 66/src/com/camilstaps/route66/Crossing.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2015 Camil Staps - */ -package com.camilstaps.route66; - -import OO14route66.Direction; -import OO14route66.Model; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author camilstaps - */ -public class Crossing { -     -    private final Model model; -    private Direction allowed; -    private boolean crossingWaiting = false; -    private int requests = 0; -     -    public Crossing(Model model, Direction allowed) { -        this.model = model; -        this.allowed = allowed; -    } -     -    public Direction getAllowed() { -        return allowed; -    } -     -    public synchronized void doSwitch() { -        crossingWaiting = true; -        while (!model.isCarsOnCrossing()); -        System.err.println("Switching"); -        if (allowed == Direction.East || allowed == Direction.West) { -            allowed = Direction.North; -        } else { -            allowed = Direction.East; -        } -        requests = 0; -        System.err.println("Switched to " + allowed); -        crossingWaiting = false; -        //notifyAll(); -    } -     -    public boolean isAllowed(Direction direction) { -        return !crossingWaiting && (direction == allowed || Direction.opposite(direction) == allowed); -    } -     -    public boolean doRequest() { -        //if (++requests >= 2) { -        if (crossingWaiting) { -            return false; -        } -            doSwitch(); -            return true; -        //} -        //return false; -    } -     -} diff --git a/Week14 Route 66/src/OO14route66/Direction.java b/Week14 Route 66/src/com/camilstaps/route66/Direction.java index 14d7110..ef69caa 100644 --- a/Week14 Route 66/src/OO14route66/Direction.java +++ b/Week14 Route 66/src/com/camilstaps/route66/Direction.java @@ -1,15 +1,34 @@  /* - * To change this template, choose Tools | Templates - * and open the template in the editor. + * The MIT License (MIT) + *  + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + *  + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + *  + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + *  + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE.   */ - -package OO14route66; +package com.camilstaps.route66;  /**   * OO1route66 initial class - * @author Pieter Koopman   *   * Enumeration class for driving directions + *  + * @author Pieter Koopman, Camil Staps   */  public enum Direction  { diff --git a/Week14 Route 66/src/com/camilstaps/route66/Driver.java b/Week14 Route 66/src/com/camilstaps/route66/Driver.java index 4a323cd..ff603c8 100644 --- a/Week14 Route 66/src/com/camilstaps/route66/Driver.java +++ b/Week14 Route 66/src/com/camilstaps/route66/Driver.java @@ -1,14 +1,33 @@  /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + *  + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + *  + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + *  + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + *  + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE.   */  package com.camilstaps.route66; -import OO14route66.Car; -import OO14route66.Model;  import java.util.Random;  /**   * A Driver takes care its car doesn't collide + *    * @author Camil Staps   */  public class Driver implements Runnable { @@ -18,7 +37,7 @@ public class Driver implements Runnable {      private final Random r; -    private boolean running, waitingToCross = false; +    private boolean running = false;      private int delay;      public Driver(Car car, Model model) { @@ -28,19 +47,22 @@ public class Driver implements Runnable {      }      /** -     * Set running to false to disable driving altogether -     * @param value  +     * Stop running       */ -    public void setRunning(boolean value) { -        running = value; -    } -     -    public void setWaitingToCross(boolean value) { -        waitingToCross = value; +    public void stopRunning() { +        running = false;      } -    public boolean getWaitingToCross() { -        return waitingToCross; +    /** +     * Resume running +     */ +    public void resumeRunning() { +        if (running == false) { +            synchronized (this) { +                running = true; +                notifyAll(); +            } +        }      }      /** @@ -53,11 +75,20 @@ public class Driver implements Runnable {      }      @Override -    @SuppressWarnings("empty-statement") -    public void run() { +    /** +     * Forever wait for safety, step and pause for a pseudorandom time. +     */ +    public synchronized void run() {          running = true;          while (true) { -            while (!running || !model.isSafeLocation(car, car.getNewLocation())); +            do { +                while (!running) { +                    try { +                        wait(); +                    } catch (InterruptedException ex) { +                    } +                } +            } while (!model.isSafeLocation(car, car.getNewLocation()));              car.step(); @@ -74,7 +105,7 @@ public class Driver implements Runnable {              if (Math.abs((System.currentTimeMillis() / 1000) % Model.NUMBEROFCARS - car.getNumber()) < 2) {                  bonus = -50;              } -            Thread.sleep(Math.abs(r.nextInt(50) + delay + bonus)); +            Thread.sleep(Math.abs(r.nextInt(100) + delay + bonus));          } catch (InterruptedException ex) {}      } diff --git a/Week14 Route 66/src/OO14route66/KeyHandler.java b/Week14 Route 66/src/com/camilstaps/route66/KeyHandler.java index ab78676..eb84b6f 100644 --- a/Week14 Route 66/src/OO14route66/KeyHandler.java +++ b/Week14 Route 66/src/com/camilstaps/route66/KeyHandler.java @@ -1,16 +1,18 @@ -package OO14route66; +package com.camilstaps.route66;  import java.awt.event.KeyAdapter;  import java.awt.event.KeyEvent;  /**   * Keyboard handler of views for controller. + *    * Pressing keys changes the controller. - * @author pieterkoopman + *  + * @author Pieter Koopman, Camil Staps   */  public class KeyHandler extends KeyAdapter { -    private Controller controller; +    private final Controller controller;      public KeyHandler (Controller c) {          controller = c; diff --git a/Week14 Route 66/src/OO14route66/Model.java b/Week14 Route 66/src/com/camilstaps/route66/Model.java index ee9da42..6e43e29 100644 --- a/Week14 Route 66/src/OO14route66/Model.java +++ b/Week14 Route 66/src/com/camilstaps/route66/Model.java @@ -1,26 +1,60 @@ -package OO14route66; +/* + * The MIT License (MIT) + *  + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + *  + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + *  + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + *  + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.camilstaps.route66;  import java.util.ArrayList;  import java.util.Observable;  import javax.swing.JFrame;  /** - * OO1route66 initial class - * @author Pieter Koopman + * Route 66 model with crossing   * - * The class model holds all cars in the simulation + * The class model holds all cars in the simulation. + *  + * @author Pieter Koopman, Camil Staps   */ -public class Model extends Observable -{ +public class Model extends Observable { +          private final Car [] cars;      public static final int          DIRECTIONS = 4,          NUMBEROFCARS = 5 * DIRECTIONS;   // total number of cars in system      private final ArrayList<JFrame> views; -    //private final Crossing crossing = new Crossing(this, Direction.North); -    private Direction allowed; +    /** +     * Crossing attributes: +     *  +     * allowed - which direction is currently allowed; if East is allowed, West  +     *    is also allowed, etc. +     * crossingWaiting - whether or not the crossing is waiting for cars to  +     *    leave the crossing to switch (i.e. orange) +     * lastCrossingChange - when the crossing switched the last time +     * MIN_CROSS_TIME - the minimum time the crossing should wait before  +     *    switching again after the last switch +     */ +    private Direction allowed = Direction.East;      private boolean crossingWaiting = false;      private long lastCrossingChange = 0;      private static final int MIN_CROSS_TIME = 1000; @@ -49,7 +83,7 @@ public class Model extends Observable      }      /** -     * get a car from the model +     * Get a car from the model       * @param i numbers of required car       * @return the car itself (not a copy)       */ @@ -58,7 +92,7 @@ public class Model extends Observable      }      /** -     * repaint all views +     * Repaint all views, and notify all drivers to reconsider driving       */      public synchronized void update() {          for (JFrame view: views) { @@ -75,11 +109,12 @@ public class Model extends Observable       * @return        */      public synchronized boolean isSafeLocation(Car car, int requested_location) { +        // Check that we don't collide with the car in front of us          Car that_car = cars[car.getNumber() < DIRECTIONS ? car.getNumber() + NUMBEROFCARS - DIRECTIONS : car.getNumber() - DIRECTIONS]; -                  boolean ok = !(that_car.getLocation() > requested_location &&                  that_car.getLocation() < requested_location + Car.CARLENGTH + Car.MINCARSPACE); +        // If we have to wait for the crossing... well, do that.          if (car.isInFrontOfCrossing() && !isCrossingAllowed(car.getDirection())) {              ok = doCrossingRequest();          } @@ -87,13 +122,16 @@ public class Model extends Observable          if (!ok) {              try {                  wait(); -            } catch (InterruptedException ex) { -            } +            } catch (InterruptedException ex) {}          }          return ok;      } +    /** +     * Check if there are any cars on the crossing +     * @return  +     */      public synchronized boolean isCarsOnCrossing() {          for (Car car : cars) {              if (car.isOnCrossing()) { @@ -103,29 +141,44 @@ public class Model extends Observable          return false;      } +    /** +     * Switch the crossing +     */      public synchronized void doSwitchCrossing() {          crossingWaiting = true; +                  while (isCarsOnCrossing()) {              try {                  wait();              } catch (InterruptedException ex) {              }          } -        System.err.println("Switching"); +                  if (allowed == Direction.East || allowed == Direction.West) {              allowed = Direction.North;          } else {              allowed = Direction.East;          } -        System.err.println("Switched to " + allowed); +                  crossingWaiting = false;          lastCrossingChange = System.currentTimeMillis();      } +    /** +     * Check if crossing in some direction is allowed +     * @param direction +     * @return  +     */      public synchronized boolean isCrossingAllowed(Direction direction) {          return !crossingWaiting && (direction == allowed || Direction.opposite(direction) == allowed);      } +    /** +     * Try to switch the crossing +     * This may return false without even trying to switch, if it's too early to +     * ask (see {@link Model#MIN_CROSS_TIME}) or if a request has been made already. +     * @return  +     */      public synchronized boolean doCrossingRequest() {          if (crossingWaiting || System.currentTimeMillis() - lastCrossingChange < MIN_CROSS_TIME) {              return false; diff --git a/Week14 Route 66/src/OO14route66/RoadView.java b/Week14 Route 66/src/com/camilstaps/route66/RoadView.java index 4495822..660d44e 100644 --- a/Week14 Route 66/src/OO14route66/RoadView.java +++ b/Week14 Route 66/src/com/camilstaps/route66/RoadView.java @@ -1,4 +1,27 @@ -package OO14route66; +/* + * The MIT License (MIT) + *  + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + *  + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + *  + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + *  + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.camilstaps.route66;  import java.awt.Color;  import java.awt.Graphics; @@ -7,9 +30,10 @@ import javax.swing.JPanel;  /**   * OO13route66 animation - * @author Pieter Koopman   *   * Yields a graphical view on all cars + *  + * @author Pieter Koopman, Camil Staps   */  public class RoadView extends JFrame  { @@ -85,10 +109,18 @@ public class RoadView extends JFrame          }      } +    /** +     * Get the relevant half of the coordinate where the crossing starts +     * @return  +     */      public static int getStartCrossing() {          return (WINDOWSIZE / 2) - Car.CARWIDTH - 4;      } +    /** +     * Get the relevant half of the coordinate where the crossing ends +     * @return  +     */      public static int getEndCrossing() {          return getStartCrossing() + 2 * Car.CARWIDTH + 8;      } diff --git a/Week14 Route 66/src/OO14route66/Route66.java b/Week14 Route 66/src/com/camilstaps/route66/Route66.java index f6b3f1f..8f9a2e9 100644 --- a/Week14 Route 66/src/OO14route66/Route66.java +++ b/Week14 Route 66/src/com/camilstaps/route66/Route66.java @@ -1,9 +1,11 @@ -package OO14route66; +package com.camilstaps.route66;  /**   * OO1route66 initial class - * @author Pieter Koopman + *    * Route66 class constructs model, view and controller + *  + * @author Pieter Koopman   */  public class Route66  { diff --git a/Week14 Route 66/src/OO14route66/TableView.java b/Week14 Route 66/src/com/camilstaps/route66/TableView.java index 9f2546f..1aa38f7 100644 --- a/Week14 Route 66/src/OO14route66/TableView.java +++ b/Week14 Route 66/src/com/camilstaps/route66/TableView.java @@ -1,4 +1,4 @@ -package OO14route66; +package com.camilstaps.route66;  import java.awt.Graphics;  import java.awt.GridLayout; diff --git a/Week14 Route 66/src/com/camilstaps/route66/Week14Route66.java b/Week14 Route 66/src/com/camilstaps/route66/Week14Route66.java deleted file mode 100644 index 30b7bd2..0000000 --- a/Week14 Route 66/src/com/camilstaps/route66/Week14Route66.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2015 Camil Staps - */ -package com.camilstaps.route66; - -/** - * - * @author camilstaps - */ -public class Week14Route66 { - -    /** -     * @param args the command line arguments -     */ -    public static void main(String[] args) { -        // TODO code application logic here -    } -     -} | 
