aboutsummaryrefslogtreecommitdiff
path: root/Week14 Route 66/src/com/camilstaps/route66/Overviewer.java
diff options
context:
space:
mode:
Diffstat (limited to 'Week14 Route 66/src/com/camilstaps/route66/Overviewer.java')
-rw-r--r--Week14 Route 66/src/com/camilstaps/route66/Overviewer.java64
1 files changed, 0 insertions, 64 deletions
diff --git a/Week14 Route 66/src/com/camilstaps/route66/Overviewer.java b/Week14 Route 66/src/com/camilstaps/route66/Overviewer.java
deleted file mode 100644
index 844f40c..0000000
--- a/Week14 Route 66/src/com/camilstaps/route66/Overviewer.java
+++ /dev/null
@@ -1,64 +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 com.camilstaps.route66;
-
-import OO14route66.Car;
-import OO14route66.Model;
-
-/**
- * The Overviewer (always only one instance) tells Drivers when they can drive
- *
- * @author Camil Staps
- */
-public class Overviewer {
-
- /**
- * This is a singleton
- */
- private static Overviewer instance;
-
- Car[] cars = new Car[Model.NUMBEROFCARS];
-
- /**
- * This is a singleton
- * @return the instance
- */
- public static Overviewer getInstance() {
- if (instance == null) {
- instance = new Overviewer();
- }
- return instance;
- }
-
- /**
- * Add a car to the list of cars
- * @param car
- */
- public synchronized void hello(Car car) {
- cars[car.getNumber()] = car;
- }
-
- /**
- * Check if a location is safe for a car to go to. This should always be
- * checked by a driver before actually driving.
- * @param car
- * @param requested_location
- * @return
- */
- public synchronized boolean isSafeLocation(Car car, int requested_location) {
- for (Car that_car : cars) {
- if (that_car != null && 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;
- }
-
-}