This is java program-I need the complelte program and the testdriver for the pro
ID: 663591 • Letter: T
Question
This is java program-I need the complelte program and the testdriver for the progam. I also need UML
"Create a system to simulate vehicles at an intersection. Assume that there is one lane going in each of four directions, with stoplights facing each direction. Vary the arrival average of vehicles in each direction and the frequency of the light changes to view the "behavior" of the intersection."
You canNOT use the Java built-in Queue or Deque class. Use an Array or Linked List implementation of a queue as explained in the text.
Include user-defined exceptions and javadoc comments.
Be sure to test thoroughly, and document your results.
Be sure to label your outputs so that when I run your code I can readily understand what you're doing
Explanation / Answer
import java.util.*;
import java.lang.*;
import java.io.*;
class light{
boolean red;
boolean green;
public light(){
red = false;
green = false;
}
}
class vehicle{
boolean stop;
boolean start;
vehicle(){
start = true;
stop = false;
}
}
class lane{
light f = new light();
Vehicle[] vh = new Vehicle[1000];
void status(){
if (f.red == true){
for (int i = 0; i < 1000; i++){
left.vh[i].stop = true;
left.vh[i].start = false;
}
}
if (f.green == true){
for (int i = 0; i < 1000; i++){
left.vh[i].stop = false;
left.vh[i].start = true;
}
}
}
}
class Ideone{
public static void main (String[] args) throws java.lang.Exception{
lane left = new lane();
lane right = new lane();
lane front = new lane();
lane back = new lane();
while (true){ // replace this true with some time and change the color of lights accordingly before going in this loop
left.status();
right.status();
front.status();
back.status();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.