aboutsummaryrefslogtreecommitdiff
path: root/Week14 Route 66/src/OO14route66/Regelaar.java
diff options
context:
space:
mode:
authorCamil Staps2015-05-29 08:16:55 +0200
committerCamil Staps2015-05-29 08:16:55 +0200
commita6183f57e9d432feae273c0b294cf90d3e97d835 (patch)
tree3e710a81f4da526142e809e5057ee60f782c651b /Week14 Route 66/src/OO14route66/Regelaar.java
parentAdded w14 to readme (diff)
comments; cleanup
Diffstat (limited to 'Week14 Route 66/src/OO14route66/Regelaar.java')
-rw-r--r--Week14 Route 66/src/OO14route66/Regelaar.java53
1 files changed, 0 insertions, 53 deletions
diff --git a/Week14 Route 66/src/OO14route66/Regelaar.java b/Week14 Route 66/src/OO14route66/Regelaar.java
deleted file mode 100644
index bf4cbfd..0000000
--- a/Week14 Route 66/src/OO14route66/Regelaar.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package OO14route66;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @author pieterkoopman
- */
-public class Regelaar {
-
- private static Regelaar instance;
-
- Map<Car, Integer> locations;
-
- protected Regelaar() {
- locations = new HashMap<>();
- }
-
- public static Regelaar getInstance() {
- if (instance == null) {
- instance = new Regelaar();
- }
- return instance;
- }
-
- public synchronized void setLocation(Car car, int location) {
- if (locations.containsKey(car)) {
- locations.remove(car);
- }
- locations.put(car, location);
- }
-
- public synchronized boolean isSafeLocation(Car car, int requested_location) {
- for (Map.Entry<Car, Integer> location : locations.entrySet()) {
- Car that_car = location.getKey();
- if (that_car != car &&
- that_car.getDirection() == car.getDirection() &&
- that_car.getLocation() > requested_location &&
- that_car.getLocation() < requested_location + Car.CARLENGTH + Car.MINCARSPACE) {
- return false;
- }
- }
- return true;
- }
-
-}