An open API service indexing awesome lists of open source software.

https://github.com/mosheberman/trafficlight

TrafficLight is a Java homework assigned in one of my classes this semester, at Brooklyn College. (Spring 2013)
https://github.com/mosheberman/trafficlight

Last synced: 10 months ago
JSON representation

TrafficLight is a Java homework assigned in one of my classes this semester, at Brooklyn College. (Spring 2013)

Awesome Lists containing this project

README

          

TrafficLight
============

TrafficLight is a Java homework assigned in one of my classes this semester, at Brooklyn College. (Spring 2013)

![Green Light, Button Disabled](./screenshots/green.png)
![Green Light, Button Enabled](./screenshots/green-button.png)
![Yellow Light](./screenshots/yellow.png)
![Red Light](./screenshots/red.png)

What It Does:
---
The StopLight class simulates a traffic light at an intersection. The light remains green for 50 seconds, turns yellow for 10 seconds, and then red for 60 seconds.

The Cross Button:
---
The Cross button becomes enabled when the light is green, but only ten seconds after the light has switched from red to green. Clicking on it accelerates the light, by immediately cycling to yellow. This way, it becomes safe to cross sooner, because the yellow light becomes red after ten seconds.

Threading:
---
StopLight.java utilizes a Thread subclass to drive the timer loop of the light cycle. It calls a synchronized method on the StopLight which should cycle the light. It won't if the button is in the middle of causing a change, though.

License:
---
Feel free to inspect my coding style, but don't redistribute it.