From 3ccaa674fdbd3408d4cbea3ed9abb02c14433b9c Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 29 May 2015 13:17:53 +0200 Subject: licensing; reorganisation; javadoc; cleanup --- .../src/com/camilstaps/route66/Crossing.java | 61 ---------------------- 1 file changed, 61 deletions(-) delete mode 100644 Week14 Route 66/src/com/camilstaps/route66/Crossing.java (limited to 'Week14 Route 66/src/com/camilstaps/route66/Crossing.java') 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; - } - -} -- cgit v1.2.3