|
Sure, this is doable. I probably wouldn't use Java for a real life traffic control system, but for simulations yeah its good to go.
What you describe sounds like it would fit well with the state change / observation pattern (if you're unfamiliar, a control object simply tracks objects that 'watch' them and notify them of any changes). Actually, I think Java has a built-in Observer and Notifier class, so you may need to poke around for that. If not, they are a cinch to make.
The real tricky part will be setting up all the watches properly. A car could watch a light and react to its changes, but if it doesn't react to other car's changes than you would create a massive pileup since they would all run into each other. It won't be that difficult to add these things in either, but you will need proper planning or you will end up with a disaster in the end.
Then adding multiple lights (which listen to other lights for changes), more cars, lanes, intersections and so forth would be trivial. Intersection feels like it will be a worthwhile class.
What would be neat is to have a driver as well that is rated for carelessness, and will take random chances on red lights O.o. Heh, see how the other drivers react to the carelessness based on their own carelessness level.
__________________
PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');
|