2. LightValue enum
Write a simple Enum named LightValue, which lists the phases a particular stoplight lane may
be in. These states should include GREEN, RED, and LEFT_SIGNAL (we are considering
yellow to be part of green). Each TwoWayRoad instance (defined below) will have its own
LightValue, which should correspond to the following rules:
GREEN indicates that the right and middle lanes may proceed, but the left lane cannot (for both
directions).
RED indicates that no lane may proceed (for both directions).
LEFT_SIGNAL indicates that left can proceed, but the right and middle lanes cannot (for both
directions).
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection
is serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and
the time it arrived (stored as an int). The car must be initialized with a serialId and the time it
arrived. The serial counter is static and stores the number of vehicles that have arrived at the
intersection so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId
to its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you must use
inheritance (extend a Java API class) to simplify the class definition.
5. TwoWayRoad Class
Write a fully documented class called TwoWayRoad that represents one of the roads in our
intersection. Each road it bi-directional, with each direction having three lanes - a left turn lane, a
middle lane, and a right turn lane. Lanes, modelled.
1. BooleanSourceHW4 class
public BooleanSourceHW4(double initProbability)
public boolean occursHW4()
Brief:
Method which returns true with the probability indicated by the member variable probability.
Preconditions:
probability is a valid probability (0 < probability 1).
Returns:
Boolean value indicating whether an event has occurred or not.
2. LightValue enum
Write a simple Enum named LightValue, which lists the phases a particular stoplight lane may
be in. These states should include GREEN, RED, and LEFT_SIGNAL (we are considering
yellow to be part of green). Each TwoWayRoad instance (defined below) will have its own
LightValue, which should correspond to the following rules:
GREEN indicates that the right and middle lanes may proceed, but the left lane cannot (for both
directions).
RED indicates that no lane may proceed (for both directions).
LEFT_SIGNAL indicates that left can proceed, but the right and middle lanes cannot (for both
directions).
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection
is serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and
the time it arrived (stored as an int). The car must be initialized with a serialId and the time it
arrived. The serial counter is static and stores the number of vehicles that have arrived at the
intersection so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId
to its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you m.
Cars in a particular lane may proceed dequeue one car per t.pdfagmbro1
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection is
serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and the
time it arrived (stored as an int). The car must be initialized with a serialId and the time it arrived.
The serial counter is static and stores the number of vehicles that have arrived at the intersection
so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId to
its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you must use inheritance
(extend a Java API class) to simplify the class definition.
5. TwoWayRoad Class
Write a fully documented class called TwoWayRoad that represents one of the roads in our
intersection. Each road it bi-directional, with each direction having three lanes - a left turn lane, a
middle lane, and a right turn lane. Lanes, modelled by VehicleQueues, hold the vehicles before
they pass through the intersection. These lanes will be stored in a two dimensional array - the first
index indicates the direction of travel on the road, and the second index indicates the lane on the
road. In order to access a specific direction, you should use the constants FORWARD_WAY and
BACKWARD_WAY to access the directions of the road. In order to access specific lanes in a
particular direction, you should use the second dimension of the array, accessed by the consants
LEFT_LANE, MIDDLE_LANE, RIGHT_LANE. Your TwoWayRoad class must be able to check
whether any of .
3 Vehicle Class Write a fully documented class named Vehicl.pdfabhishekcctv
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection is
serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and the
time it arrived (stored as an int). The car must be initialized with a serialId and the time it arrived.
The serial counter is static and stores the number of vehicles that have arrived at the intersection
so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId to
its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you must use inheritance
(extend a Java API class) to simplify the class definition.
5. TwoWayRoad Class
Write a fully documented class called TwoWayRoad that represents one of the roads in our
intersection. Each road it bi-directional, with each direction having three lanes - a left turn lane, a
middle lane, and a right turn lane. Lanes, modelled by VehicleQueues, hold the vehicles before
they pass through the intersection. These lanes will be stored in a two dimensional array - the first
index indicates the direction of travel on the road, and the second index indicates the lane on the
road. In order to access a specific direction, you should use the constants FORWARD_WAY and
BACKWARD_WAY to access the directions of the road. In order to access specific lanes in a
particular direction, you should use the second dimension of the array, accessed by the consants
LEFT_LANE, MIDDLE_LANE, RIGHT_LANE. Your TwoWayRoad class must be able to check
whether any of the lanes in the road have Vehicle objects in them by using the boolean
isEmpty(int wayIndex, int laneIndex) method. It should also be able to add Vehicle objects to the
lanes using the void enqueueVehicle(int wayIndex, int l.
3 Vehicle Class Write a fully documented class named Vehicl.pdfVANDANASINHACONSULT
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection is
serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and the
time it arrived (stored as an int). The car must be initialized with a serialId and the time it arrived.
The serial counter is static and stores the number of vehicles that have arrived at the intersection
so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId to
its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you must use inheritance
(extend a Java API class) to simplify the class definition.
5. TwoWayRoad Class
Write a fully documented class called TwoWayRoad that represents one of the roads in our
intersection. Each road it bi-directional, with each direction having three lanes - a left turn lane, a
middle lane, and a right turn lane. Lanes, modelled by VehicleQueues, hold the vehicles before
they pass through the intersection. These lanes will be stored in a two dimensional array - the first
index indicates the direction of travel on the road, and the second index indicates the lane on the
road. In order to access a specific direction, you should use the constants FORWARD_WAY and
BACKWARD_WAY to access the directions of the road. In order to access specific lanes in a
particular direction, you should use the second dimension of the array, accessed by the consants
LEFT_LANE, MIDDLE_LANE, RIGHT_LANE. Your TwoWayRoad class must be able to check
whether any of the lanes in the road have Vehicle objects in them by using the boolean
isEmpty(int wayIndex, int laneIndex) method. It should also be able to add Vehicle objects to the
lanes using the void enqueueVehicle(int wayIndex, int l.
1. BooleanSourceHW4 class
public BooleanSourceHW4(double initProbability)
Brief:
Constructor which initializes the probability to the indicated parameter.
Parameters:
initProbability
Probability used to construct this BooleanSourceHW4 object. The probability should be greater
than 0 and less than or equal to 1.
Preconditions:
0 < initProbability 1.
Throws:
IllegalArgumentException
If initProbability 0 or initProbability > 1.
public boolean occursHW4()
Brief:
Method which returns true with the probability indicated by the member variable probability.
Preconditions:
probability is a valid probability (0 < probability 1).
Returns:
Boolean value indicating whether an event has occurred or not.
2. LightValue enum
Write a simple Enum named LightValue, which lists the phases a particular stoplight lane may
be in. These states should include GREEN, RED, and LEFT_SIGNAL (we are considering
yellow to be part of green). Each TwoWayRoad instance (defined below) will have its own
LightValue, which should correspond to the following rules:
GREEN indicates that the right and middle lanes may proceed, but the left lane cannot (for both
directions).
RED indicates that no lane may proceed (for both directions).
LEFT_SIGNAL indicates that left can proceed, but the right and middle lanes cannot (for both
directions).
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection
is serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and
the time it arrived (stored as an int). The car must be initialized with a serialId and the time it
arrived. The serial counter is static and stores the number of vehicles that have arrived at the
intersection so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId
to its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement .
1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdfatwaytvl
1. BooleanSourceHW4 class
public BooleanSourceHW4(double initProbability)
Brief:
Constructor which initializes the probability to the indicated parameter.
Parameters:
initProbability
Probability used to construct this BooleanSourceHW4 object. The probability should be greater
than 0 and less than or equal to 1.
Preconditions:
0 < initProbability 1.
Throws:
IllegalArgumentException
If initProbability 0 or initProbability > 1.
public boolean occursHW4()
Brief:
Method which returns true with the probability indicated by the member variable probability.
Preconditions:
probability is a valid probability (0 < probability 1).
Returns:
Boolean value indicating whether an event has occurred or not.
2. LightValue enum
Write a simple Enum named LightValue, which lists the phases a particular stoplight lane may be
in. These states should include GREEN, RED, and LEFT_SIGNAL (we are considering yellow to
be part of green). Each TwoWayRoad instance (defined below) will have its own LightValue, which
should correspond to the following rules:
GREEN indicates that the right and middle lanes may proceed, but the left lane cannot (for both
directions).
RED indicates that no lane may proceed (for both directions).
LEFT_SIGNAL indicates that left can proceed, but the right and middle lanes cannot (for both
directions).
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection is
serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and the
time it arrived (stored as an int). The car must be initialized with a serialId and the time it arrived.
The serial counter is static and stores the number of vehicles that have arrived at the intersection
so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId to
its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement .
Create a system to simulate vehicles at an intersection. Assume th.pdfarchanacomputers1
\"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. This means a jsjf package containing
QueueADT.java file with CircularArrayQueue.java or LinkedQueue.java and LinearNode.java.
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.
Determine what is the optimal light-change time to maximize car throughput.
WANT KNOW HOW CAN I MAKE IT RUN!
import java.lang.Math;
import java.io.*;
import jsjf.*;
import jsjf.exceptions.*;
import java.util.*;
import java.net.*;
import java.io.*;
/**
*This class is where all action resides. It contains all the queues that represent the lanes at the
intersection.
* It also contains all methods that pertain to populating the intersection and moving the vehicles
in their
* retrospective directions.
*/
public class Simulator {
/** This queue will hold only vehicle objects that enter in the left lane on Main Street headed
East. */
private LinkedQueue EMainL = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the right lane on Main Street headed
East. */
private LinkedQueue EMainR = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the left lane on Main Street headed
West. */
private LinkedQueue WMainL = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the right lane on Main Street headed
West. */
private LinkedQueue WMainR = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the left lane on Church Street
headed North. */
private LinkedQueue NChurchL = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the right lane on Church Street
headed North. */
private LinkedQueue NChurchR = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the left lane on Church Street
headed South. */
private LinkedQueue SChurchL = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the right lane on Church Street
headed South. */
private LinkedQueue SChurchR = new LinkedQueue();
/** This integer value will keep track of the current time during the simulation.*/
int time = 0;
/** This integer value will be used to make sure only two vehicles move during each light
change for each lane. */
int i = 0;
/** This integer value will keep track of the vehicle numbers of the cars that arrive at the
intersection. */
int vehicleNum = 1;
/** This creates a filewriter object that allows us for the ability to write streams o.
Design functional solutions in Java, a practical exampleMarian Wamsiedel
Starting with a simple programming task I present here some solutions based on functional programming and a standard object oriented one.
The code samples are written in Java. A github repository contains the complete code implementation.
1. BooleanSourceHW4 class
public BooleanSourceHW4(double initProbability)
public boolean occursHW4()
Brief:
Method which returns true with the probability indicated by the member variable probability.
Preconditions:
probability is a valid probability (0 < probability 1).
Returns:
Boolean value indicating whether an event has occurred or not.
2. LightValue enum
Write a simple Enum named LightValue, which lists the phases a particular stoplight lane may
be in. These states should include GREEN, RED, and LEFT_SIGNAL (we are considering
yellow to be part of green). Each TwoWayRoad instance (defined below) will have its own
LightValue, which should correspond to the following rules:
GREEN indicates that the right and middle lanes may proceed, but the left lane cannot (for both
directions).
RED indicates that no lane may proceed (for both directions).
LEFT_SIGNAL indicates that left can proceed, but the right and middle lanes cannot (for both
directions).
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection
is serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and
the time it arrived (stored as an int). The car must be initialized with a serialId and the time it
arrived. The serial counter is static and stores the number of vehicles that have arrived at the
intersection so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId
to its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you m.
Cars in a particular lane may proceed dequeue one car per t.pdfagmbro1
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection is
serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and the
time it arrived (stored as an int). The car must be initialized with a serialId and the time it arrived.
The serial counter is static and stores the number of vehicles that have arrived at the intersection
so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId to
its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you must use inheritance
(extend a Java API class) to simplify the class definition.
5. TwoWayRoad Class
Write a fully documented class called TwoWayRoad that represents one of the roads in our
intersection. Each road it bi-directional, with each direction having three lanes - a left turn lane, a
middle lane, and a right turn lane. Lanes, modelled by VehicleQueues, hold the vehicles before
they pass through the intersection. These lanes will be stored in a two dimensional array - the first
index indicates the direction of travel on the road, and the second index indicates the lane on the
road. In order to access a specific direction, you should use the constants FORWARD_WAY and
BACKWARD_WAY to access the directions of the road. In order to access specific lanes in a
particular direction, you should use the second dimension of the array, accessed by the consants
LEFT_LANE, MIDDLE_LANE, RIGHT_LANE. Your TwoWayRoad class must be able to check
whether any of .
3 Vehicle Class Write a fully documented class named Vehicl.pdfabhishekcctv
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection is
serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and the
time it arrived (stored as an int). The car must be initialized with a serialId and the time it arrived.
The serial counter is static and stores the number of vehicles that have arrived at the intersection
so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId to
its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you must use inheritance
(extend a Java API class) to simplify the class definition.
5. TwoWayRoad Class
Write a fully documented class called TwoWayRoad that represents one of the roads in our
intersection. Each road it bi-directional, with each direction having three lanes - a left turn lane, a
middle lane, and a right turn lane. Lanes, modelled by VehicleQueues, hold the vehicles before
they pass through the intersection. These lanes will be stored in a two dimensional array - the first
index indicates the direction of travel on the road, and the second index indicates the lane on the
road. In order to access a specific direction, you should use the constants FORWARD_WAY and
BACKWARD_WAY to access the directions of the road. In order to access specific lanes in a
particular direction, you should use the second dimension of the array, accessed by the consants
LEFT_LANE, MIDDLE_LANE, RIGHT_LANE. Your TwoWayRoad class must be able to check
whether any of the lanes in the road have Vehicle objects in them by using the boolean
isEmpty(int wayIndex, int laneIndex) method. It should also be able to add Vehicle objects to the
lanes using the void enqueueVehicle(int wayIndex, int l.
3 Vehicle Class Write a fully documented class named Vehicl.pdfVANDANASINHACONSULT
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection is
serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and the
time it arrived (stored as an int). The car must be initialized with a serialId and the time it arrived.
The serial counter is static and stores the number of vehicles that have arrived at the intersection
so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId to
its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you must use inheritance
(extend a Java API class) to simplify the class definition.
5. TwoWayRoad Class
Write a fully documented class called TwoWayRoad that represents one of the roads in our
intersection. Each road it bi-directional, with each direction having three lanes - a left turn lane, a
middle lane, and a right turn lane. Lanes, modelled by VehicleQueues, hold the vehicles before
they pass through the intersection. These lanes will be stored in a two dimensional array - the first
index indicates the direction of travel on the road, and the second index indicates the lane on the
road. In order to access a specific direction, you should use the constants FORWARD_WAY and
BACKWARD_WAY to access the directions of the road. In order to access specific lanes in a
particular direction, you should use the second dimension of the array, accessed by the consants
LEFT_LANE, MIDDLE_LANE, RIGHT_LANE. Your TwoWayRoad class must be able to check
whether any of the lanes in the road have Vehicle objects in them by using the boolean
isEmpty(int wayIndex, int laneIndex) method. It should also be able to add Vehicle objects to the
lanes using the void enqueueVehicle(int wayIndex, int l.
1. BooleanSourceHW4 class
public BooleanSourceHW4(double initProbability)
Brief:
Constructor which initializes the probability to the indicated parameter.
Parameters:
initProbability
Probability used to construct this BooleanSourceHW4 object. The probability should be greater
than 0 and less than or equal to 1.
Preconditions:
0 < initProbability 1.
Throws:
IllegalArgumentException
If initProbability 0 or initProbability > 1.
public boolean occursHW4()
Brief:
Method which returns true with the probability indicated by the member variable probability.
Preconditions:
probability is a valid probability (0 < probability 1).
Returns:
Boolean value indicating whether an event has occurred or not.
2. LightValue enum
Write a simple Enum named LightValue, which lists the phases a particular stoplight lane may
be in. These states should include GREEN, RED, and LEFT_SIGNAL (we are considering
yellow to be part of green). Each TwoWayRoad instance (defined below) will have its own
LightValue, which should correspond to the following rules:
GREEN indicates that the right and middle lanes may proceed, but the left lane cannot (for both
directions).
RED indicates that no lane may proceed (for both directions).
LEFT_SIGNAL indicates that left can proceed, but the right and middle lanes cannot (for both
directions).
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection
is serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and
the time it arrived (stored as an int). The car must be initialized with a serialId and the time it
arrived. The serial counter is static and stores the number of vehicles that have arrived at the
intersection so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId
to its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement .
1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdfatwaytvl
1. BooleanSourceHW4 class
public BooleanSourceHW4(double initProbability)
Brief:
Constructor which initializes the probability to the indicated parameter.
Parameters:
initProbability
Probability used to construct this BooleanSourceHW4 object. The probability should be greater
than 0 and less than or equal to 1.
Preconditions:
0 < initProbability 1.
Throws:
IllegalArgumentException
If initProbability 0 or initProbability > 1.
public boolean occursHW4()
Brief:
Method which returns true with the probability indicated by the member variable probability.
Preconditions:
probability is a valid probability (0 < probability 1).
Returns:
Boolean value indicating whether an event has occurred or not.
2. LightValue enum
Write a simple Enum named LightValue, which lists the phases a particular stoplight lane may be
in. These states should include GREEN, RED, and LEFT_SIGNAL (we are considering yellow to
be part of green). Each TwoWayRoad instance (defined below) will have its own LightValue, which
should correspond to the following rules:
GREEN indicates that the right and middle lanes may proceed, but the left lane cannot (for both
directions).
RED indicates that no lane may proceed (for both directions).
LEFT_SIGNAL indicates that left can proceed, but the right and middle lanes cannot (for both
directions).
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection is
serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and the
time it arrived (stored as an int). The car must be initialized with a serialId and the time it arrived.
The serial counter is static and stores the number of vehicles that have arrived at the intersection
so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId to
its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement .
Create a system to simulate vehicles at an intersection. Assume th.pdfarchanacomputers1
\"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. This means a jsjf package containing
QueueADT.java file with CircularArrayQueue.java or LinkedQueue.java and LinearNode.java.
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.
Determine what is the optimal light-change time to maximize car throughput.
WANT KNOW HOW CAN I MAKE IT RUN!
import java.lang.Math;
import java.io.*;
import jsjf.*;
import jsjf.exceptions.*;
import java.util.*;
import java.net.*;
import java.io.*;
/**
*This class is where all action resides. It contains all the queues that represent the lanes at the
intersection.
* It also contains all methods that pertain to populating the intersection and moving the vehicles
in their
* retrospective directions.
*/
public class Simulator {
/** This queue will hold only vehicle objects that enter in the left lane on Main Street headed
East. */
private LinkedQueue EMainL = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the right lane on Main Street headed
East. */
private LinkedQueue EMainR = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the left lane on Main Street headed
West. */
private LinkedQueue WMainL = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the right lane on Main Street headed
West. */
private LinkedQueue WMainR = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the left lane on Church Street
headed North. */
private LinkedQueue NChurchL = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the right lane on Church Street
headed North. */
private LinkedQueue NChurchR = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the left lane on Church Street
headed South. */
private LinkedQueue SChurchL = new LinkedQueue();
/** This queue will hold only vehicle objects that enter in the right lane on Church Street
headed South. */
private LinkedQueue SChurchR = new LinkedQueue();
/** This integer value will keep track of the current time during the simulation.*/
int time = 0;
/** This integer value will be used to make sure only two vehicles move during each light
change for each lane. */
int i = 0;
/** This integer value will keep track of the vehicle numbers of the cars that arrive at the
intersection. */
int vehicleNum = 1;
/** This creates a filewriter object that allows us for the ability to write streams o.
Design functional solutions in Java, a practical exampleMarian Wamsiedel
Starting with a simple programming task I present here some solutions based on functional programming and a standard object oriented one.
The code samples are written in Java. A github repository contains the complete code implementation.
T HE PASSENGER VEHICLE ' S LOGISTICS TRANSPORTATION PLANNING PROBLEM BASED O...ijcsa
In order to solve the heterogeneous vehicle routing
problem with two-dimensional loading constraint, a
n
integer programming model of the heterogeneous vehi
cle's routing problem has been founded. To optimize
the loading way of the 45 kind of passenger car by
quantum genetic algorithm (QGA), firstly the QGA is
adopted to get the assemble of each passenger car,
then analysis the routing problem of the each car-
carrier. The optimization of integer programming pr
oblems and the simulation and application of QGA ar
e
discussed specifically.
Fabrication of Automatic Guided Vehicle Ajith Aravind
Automatic Guided vehicle (AGV) is a part of flexible manufacturing system. Now a days large manufacturing industries use the transportation systems foe various transportation purposes. various types of AGVs are available. Manufacturing and installation of this system is a tough task. The vehicle is designed according to the need and type of transportation, material to be transformed etc.
This is a full report of my project in Level 3 Term 1. The project was basically a self-driven vehicle capable of localizing itself in a grid and planning a path between two nodes. It can avoid particular nodes and plan path between two allowed nodes. Flood Fill Algorithm will be used for finding the path between two allowed nodes. The vehicle is also capable of transferring blocks from one node to another. In fact, this vehicle is a prototype of a self-driven vehicle capable of transporting passengers and it can also be used in industries to transfer different items from one place to another.
Simulation of traffic queues in a junction with lightsIt has been .pdfleolight2
Simulation of traffic queues in a junction with lights
It has been determined that the traffic flow in the junction below is not satisfactory, there are
often long queues.
The junction is controlled by the four light signals s1, s2, s3 and s4.
A significant part of the traffic that comes from E, to the right in the figure, is to turn left towards
S in the junction but they are often blocked by vehicles that comes from W. To solve this
problem, an additional lane for vehicles that comes from E respective W that are
to turn left in the junction, i.e. we would like to have a junction like this:
This junction does have additional lanes controlled by the light signals s2 and s5.
To determine the length of these lanes, we would like to have a program that simulates the traffic
flow in the crossing at different lengths of these turning" lanes, different traffic intensity and
different cycles of the light signals. To do this it is enough to study the flow in one direction, i.e.
in a system like this:
Since traffic from E aiming to both N and W are controlled by the same light signal (s1) we dont
need to separate these. We treat this traffic as aiming to W. We dont need to track the vehicles
when they have left the crossing.
Computer model
We represent a lane with an array where each element is either empty (null) or a vehicle (all
vehicles are assumed to have the same size).
The system consists of the lanes (r0, r1 and r2) and two light signals (s1 and s2):
In a time step one or more of the following events may occur:
_ a signal changes color.
_ a vehicle passes a signal (if it shows green).
_ a vehicle advances one step in a lane (if the place before it is free).
_ the vehicle immediately before X (i.e. in link list r0[0]) is moved to r1 or r2 depending on its
destination (W or S),
_ a vehicle arrives to the system at the point E.
A simulation consists of a time stepping where the events above occur.
The function of the light signals
A signal is green or red (no yellow light is needed). A signal is characterized by two parameters:
_ a period i.e. the number of time steps from the start of one green cycle to the start of the next.
_ a greenperiod i.e. the number of timesteps the signal is green.
These parameters are assigned when the light signal is built (ie as parameters to the constructor).
A signal needs an internal clock that is ticked by a step-method. It is a good idea (but not
necessary) to let the clock be circular, ie when it reaches the end of the period, it is reset to zero.
You also need a method that decides whether the signal is green or not.
Both signals should have the same period and start as green.
Example: If the period is 7 and the green period for s1 is 3 and fore s2 is 2, the table below
shows how the internal clock should tick and what color they show
Simulation
The program is controlled by the following parameters:
_ The length of the lanes. The lanes r1 and r2 always have the same length.
_ Probability of an arrival, i.e. th.
Implementation of D* Path Planning Algorithm with NXT LEGO Mindstorms Kit for...idescitation
Autonomous Robots use various Path Planning
algorithms to navigate, to the target point. In the real world
situation robot may not have a complete picture of the obstacles
in its environment. The classical path planning algorithms
such as A*, D* are cost based where the shortest path to the
target is calculated based on the distance to be travelled. In
order to provide real time shortest path solutions, cost
computation has to be redone whenever new obstacles are
identified. D* is a potential search algorithm, capable of
planning shortest path in unknown, partially known and
changing environments. This paper brings out the simulation
of D* algorithm in C++ and the results for different test cases.
It also elucidates the implementation of the algorithm with
NXT LEGO Mindstorms kit using RobotC language and
evaluation in real time scenario.
International Journal of Engineering Research and Applications (IJERA) is an open access online peer reviewed international journal that publishes research and review articles in the fields of Computer Science, Neural Networks, Electrical Engineering, Software Engineering, Information Technology, Mechanical Engineering, Chemical Engineering, Plastic Engineering, Food Technology, Textile Engineering, Nano Technology & science, Power Electronics, Electronics & Communication Engineering, Computational mathematics, Image processing, Civil Engineering, Structural Engineering, Environmental Engineering, VLSI Testing & Low Power VLSI Design etc.
(7) cpp abstractions inheritance_part_iiNico Ludwig
- C++11: Explicit Overrides and final Methods
- Run Time Type Identification (RTTI) and dynamic_cast
- protected Members
- Abstract Types with pure virtual Member Functions
- Virtual Destructors
- Inheritance and Operators
(7) c sharp introduction_advanvced_features_part_iiNico Ludwig
This presentation comes with many additional notes (pdf): http://de.slideshare.net/nicolayludwig/7-c-sharp-introductionadvanvcedfeaturespartii-38640489
Check out these exercises: http://de.slideshare.net/nicolayludwig/6-7-c-sharp-introductionadvancedfeaturespartipartiiexercises
- Object-based and generic Collections
- Delegates and Events
- Custom Attributes
- Reflection
Application Of The Three-In-One Control Platform Based On OPC In The Lifting-...IJRES Journal
The three-in-one control platform includes MATLAB, WINCC and S7 300 PLC. In the platform, MATLAB communicates with WINCC through OPC and WINCC communicates with PLC. It is a control platform with WINCC as the bridge. The platform is designed to shorten the operating time of the lifting-sliding stereo garage, and at the same time to achieve controlling the stereo garage through monitoring interface. Genetic algorithm is designed with MATLAB for getting the optimal scheduling scheme of lifting-sliding stereo garage in the platform. Then the date was passed to WINCC through OPC. PLC conducts the scheduling of the stereo garage based on the date getting from WINCC, and through the WINCC to achieve real time picture monitoring and operating of the stereo garage. Under the same conditions, the control platform can get access to the vehicle in the shortest time.
2.1 Plan the resource requirements you would require for the project.pdfchughakshit42
2.1 Plan the resource requirements you would require for the project. Specify each resources role
and responsibility in the project. (10 Marks)
2.2 Conduct a stakeholder analysis. Indicate whether they are internal or external stakeholders.
(10 Marks).
2.Define the following terms with respect to Measurement System An.pdfchughakshit42
2.Define the following terms with respect to Measurement System Analysis (MSA):
a. Repeatability
b. Reproducibility
c. Stability
d. Linearity
e. Bias
3.The purpose of MSA is to assess any error due to inaccuracy of our measurement systems.
This error can be partitioned its specific sources. Please describe what is partitioned in precision
and what is partitioned in accuracy..
More Related Content
Similar to 2. LightValue enumWrite a simple Enum named LightValue, which list.pdf
T HE PASSENGER VEHICLE ' S LOGISTICS TRANSPORTATION PLANNING PROBLEM BASED O...ijcsa
In order to solve the heterogeneous vehicle routing
problem with two-dimensional loading constraint, a
n
integer programming model of the heterogeneous vehi
cle's routing problem has been founded. To optimize
the loading way of the 45 kind of passenger car by
quantum genetic algorithm (QGA), firstly the QGA is
adopted to get the assemble of each passenger car,
then analysis the routing problem of the each car-
carrier. The optimization of integer programming pr
oblems and the simulation and application of QGA ar
e
discussed specifically.
Fabrication of Automatic Guided Vehicle Ajith Aravind
Automatic Guided vehicle (AGV) is a part of flexible manufacturing system. Now a days large manufacturing industries use the transportation systems foe various transportation purposes. various types of AGVs are available. Manufacturing and installation of this system is a tough task. The vehicle is designed according to the need and type of transportation, material to be transformed etc.
This is a full report of my project in Level 3 Term 1. The project was basically a self-driven vehicle capable of localizing itself in a grid and planning a path between two nodes. It can avoid particular nodes and plan path between two allowed nodes. Flood Fill Algorithm will be used for finding the path between two allowed nodes. The vehicle is also capable of transferring blocks from one node to another. In fact, this vehicle is a prototype of a self-driven vehicle capable of transporting passengers and it can also be used in industries to transfer different items from one place to another.
Simulation of traffic queues in a junction with lightsIt has been .pdfleolight2
Simulation of traffic queues in a junction with lights
It has been determined that the traffic flow in the junction below is not satisfactory, there are
often long queues.
The junction is controlled by the four light signals s1, s2, s3 and s4.
A significant part of the traffic that comes from E, to the right in the figure, is to turn left towards
S in the junction but they are often blocked by vehicles that comes from W. To solve this
problem, an additional lane for vehicles that comes from E respective W that are
to turn left in the junction, i.e. we would like to have a junction like this:
This junction does have additional lanes controlled by the light signals s2 and s5.
To determine the length of these lanes, we would like to have a program that simulates the traffic
flow in the crossing at different lengths of these turning" lanes, different traffic intensity and
different cycles of the light signals. To do this it is enough to study the flow in one direction, i.e.
in a system like this:
Since traffic from E aiming to both N and W are controlled by the same light signal (s1) we dont
need to separate these. We treat this traffic as aiming to W. We dont need to track the vehicles
when they have left the crossing.
Computer model
We represent a lane with an array where each element is either empty (null) or a vehicle (all
vehicles are assumed to have the same size).
The system consists of the lanes (r0, r1 and r2) and two light signals (s1 and s2):
In a time step one or more of the following events may occur:
_ a signal changes color.
_ a vehicle passes a signal (if it shows green).
_ a vehicle advances one step in a lane (if the place before it is free).
_ the vehicle immediately before X (i.e. in link list r0[0]) is moved to r1 or r2 depending on its
destination (W or S),
_ a vehicle arrives to the system at the point E.
A simulation consists of a time stepping where the events above occur.
The function of the light signals
A signal is green or red (no yellow light is needed). A signal is characterized by two parameters:
_ a period i.e. the number of time steps from the start of one green cycle to the start of the next.
_ a greenperiod i.e. the number of timesteps the signal is green.
These parameters are assigned when the light signal is built (ie as parameters to the constructor).
A signal needs an internal clock that is ticked by a step-method. It is a good idea (but not
necessary) to let the clock be circular, ie when it reaches the end of the period, it is reset to zero.
You also need a method that decides whether the signal is green or not.
Both signals should have the same period and start as green.
Example: If the period is 7 and the green period for s1 is 3 and fore s2 is 2, the table below
shows how the internal clock should tick and what color they show
Simulation
The program is controlled by the following parameters:
_ The length of the lanes. The lanes r1 and r2 always have the same length.
_ Probability of an arrival, i.e. th.
Implementation of D* Path Planning Algorithm with NXT LEGO Mindstorms Kit for...idescitation
Autonomous Robots use various Path Planning
algorithms to navigate, to the target point. In the real world
situation robot may not have a complete picture of the obstacles
in its environment. The classical path planning algorithms
such as A*, D* are cost based where the shortest path to the
target is calculated based on the distance to be travelled. In
order to provide real time shortest path solutions, cost
computation has to be redone whenever new obstacles are
identified. D* is a potential search algorithm, capable of
planning shortest path in unknown, partially known and
changing environments. This paper brings out the simulation
of D* algorithm in C++ and the results for different test cases.
It also elucidates the implementation of the algorithm with
NXT LEGO Mindstorms kit using RobotC language and
evaluation in real time scenario.
International Journal of Engineering Research and Applications (IJERA) is an open access online peer reviewed international journal that publishes research and review articles in the fields of Computer Science, Neural Networks, Electrical Engineering, Software Engineering, Information Technology, Mechanical Engineering, Chemical Engineering, Plastic Engineering, Food Technology, Textile Engineering, Nano Technology & science, Power Electronics, Electronics & Communication Engineering, Computational mathematics, Image processing, Civil Engineering, Structural Engineering, Environmental Engineering, VLSI Testing & Low Power VLSI Design etc.
(7) cpp abstractions inheritance_part_iiNico Ludwig
- C++11: Explicit Overrides and final Methods
- Run Time Type Identification (RTTI) and dynamic_cast
- protected Members
- Abstract Types with pure virtual Member Functions
- Virtual Destructors
- Inheritance and Operators
(7) c sharp introduction_advanvced_features_part_iiNico Ludwig
This presentation comes with many additional notes (pdf): http://de.slideshare.net/nicolayludwig/7-c-sharp-introductionadvanvcedfeaturespartii-38640489
Check out these exercises: http://de.slideshare.net/nicolayludwig/6-7-c-sharp-introductionadvancedfeaturespartipartiiexercises
- Object-based and generic Collections
- Delegates and Events
- Custom Attributes
- Reflection
Application Of The Three-In-One Control Platform Based On OPC In The Lifting-...IJRES Journal
The three-in-one control platform includes MATLAB, WINCC and S7 300 PLC. In the platform, MATLAB communicates with WINCC through OPC and WINCC communicates with PLC. It is a control platform with WINCC as the bridge. The platform is designed to shorten the operating time of the lifting-sliding stereo garage, and at the same time to achieve controlling the stereo garage through monitoring interface. Genetic algorithm is designed with MATLAB for getting the optimal scheduling scheme of lifting-sliding stereo garage in the platform. Then the date was passed to WINCC through OPC. PLC conducts the scheduling of the stereo garage based on the date getting from WINCC, and through the WINCC to achieve real time picture monitoring and operating of the stereo garage. Under the same conditions, the control platform can get access to the vehicle in the shortest time.
Similar to 2. LightValue enumWrite a simple Enum named LightValue, which list.pdf (20)
2.1 Plan the resource requirements you would require for the project.pdfchughakshit42
2.1 Plan the resource requirements you would require for the project. Specify each resources role
and responsibility in the project. (10 Marks)
2.2 Conduct a stakeholder analysis. Indicate whether they are internal or external stakeholders.
(10 Marks).
2.Define the following terms with respect to Measurement System An.pdfchughakshit42
2.Define the following terms with respect to Measurement System Analysis (MSA):
a. Repeatability
b. Reproducibility
c. Stability
d. Linearity
e. Bias
3.The purpose of MSA is to assess any error due to inaccuracy of our measurement systems.
This error can be partitioned its specific sources. Please describe what is partitioned in precision
and what is partitioned in accuracy..
2. What code would you use to pick a random number and then let the .pdfchughakshit42
2. What code would you use to pick a random number and then let the user enter what number
was to be added? Write this code out. 3. How would you display information back to the user
and what all information do you think you should display? Include this in your above in python.
2. Two intersecting shear zones have the following attitudes N80E7.pdfchughakshit42
2. Two intersecting shear zones have the following attitudes: N80E/75S and N60E/52NW.
Where the two sear zones intersect hydrothermal alteration resulted in gold mineralization.
(a) What is the orientation the gold mineralized zone?
(b) What is the orientation of the plane perpendicular to the mineralized zone?.
2. the string.xml file is located in the_________resource folder. .pdfchughakshit42
2. the string.xml file is located in the_________resource folder.
A.contentprovider. B.broadcast receiver
C.activity. D.service
5. The directory that contains files for app icons(known as your launcher icon) at different screen
densities___.
a.Onload
b.oncreate
c.onstart d.onrestart.
2. Referring the following information, prepare a proper list of refer.pdfchughakshit42
2. Referring the following information, prepare a proper list of reference of an academic journal
article using APA citation format. The article entitled: Motivation as a Lens to understand online
learners: Toward datadriven design with the OLEI scale. Written by two authors namely, Rene F.
Kizilcec and Emily Schneider. The article published in ACM Transactions on Computer-Human
Interaction (April, 2015). Volume 6, consists of 24 pages (beginning with page 1). (4
marks).
2. List and describe 2 different approaches to interviewing for hiri.pdfchughakshit42
2. List and describe 2 different approaches to interviewing for hiring. What are the pros/cons of
each approach? Which one does research (and the prof) say is the best? Spend a few extra
sentences explaining the one that is the best. How does job analysis inform what you should ask
in a job interview?.
2. Gravitropism Gravitropism is growth in response to gravity. It is.pdfchughakshit42
2. Gravitropism Gravitropism is growth in response to gravity. It is a common observation that
roots tend to grow downward and stems tend to grow upward. Lateral roots are not as strongly
gravitropic as the main root. The control over the direction of lateral root growth is not
understood, although the main root seems to exert influence over the orientation of lateral roots.
A similar phenomenon can be observed in both the phototropic and gravitropic responses of
shoot systems, where the lateral stems are less directly oriented with respect to light and gravity
than the main stem. Branches must orient themselves for light reception without competing with
or shading other branches on the same plant. The mechanisms by which plants detect gravity are
not well understood, although it is an area of active research. The hormone involved is auxin.
Under normal conditions, auxin is transported toward the tip of the root, and then flows toward
the root epidermis and back up the root, and away from the tip. When a root is tipped on its side,
more auxin is distributed on the downward side of the root than on the upper side. The response
to this unequal distribution of auxin is elongation of cells on the upper side of the root, resulting
in curvature, much like that seen in the phototrophic response. Stem Gravitropism
Do both stems and roots respond to gravity as a stimulus? If they do, do they grow toward it
(positive gravitropism) or away from it (negative gravitropism)?
1. At the side table , a potted plant has been placed on its side in a darkened box. 1. Before you
look in the box, hypothesize as to what direction the stem will have grown, and why you think
so.
2. Why was the stem in a darkened box? If the stem were on its side in the light, how would this
affect your conclusions? The stem was in a darkened box to show.
2. El 2 de abril, Granger Sales decide establecer un fondo de caja c.pdfchughakshit42
2. El 2 de abril, Granger Sales decide establecer un fondo de caja chica de $125 para aliviar la
carga de Contabilidad. ? (a) Registrar en el diario el establecimiento del fondo. (b) El 10 de abril,
el fondo de caja chica tiene recibos por correo y franqueo de $43.50, contribuciones y
donaciones de? $29.50, comidas y entretenimiento de $38.25 y $13.55 en efectivo. Registrar en
el diario la reposicin del fondo. (c) El 11 de abril, Granger Sales decide aumentar la caja chica a
$200. Publica este evento en un diario.
Fecha
Diario general
Dbito
Crdito
Fecha
Diario general
Dbito
Crdito
.
2. Genel olarak, bir irket kendi sahibine aittir. A. y�neticiler..pdfchughakshit42
2. Genel olarak, bir irket kendi sahibine aittir.
A. yneticiler.
B. ynetim kurulu ve hissedarlar.
hissedarlar.
D. yneticiler, ynetim kurulu ve hissedarlar
3. Aadaki varlk trlerinden hangisi maddi olmayandr?
A. retim makineleri
B. Fabrikalar
C. Ticari markalar
D. Bro ekipman.
2. Endor Incorporated has just paid a dividend of $4.49. The firms .pdfchughakshit42
2. Endor Incorporated has just paid a dividend of $4.49. The firm's current price on common
stock is $34.99. Dividends are expected to grow at a 5% constant rate. What is the firms cost of
common equity? Give your answer as a percentage, rounded to two decimal places (example:
9.58% as 9.58).
2. Baroreceptor reflex is an example of pressure reflex autonom.pdfchughakshit42
2. Baroreceptor reflex is an example of pressure reflex autonomic reflex sensory reflex somatic
reflex
In systemic circulation, the blood is pumped out of the heart and sent to peripheral tissue, where
it gets concentrated oxygenated deoxygenated diluted.
2. Draw the MENU entity as a supertype of the PROMOTIONAL, REGULAR, .pdfchughakshit42
2. Draw the MENU entity as a supertype of the PROMOTIONAL, REGULAR, and OTHER
entities. The UID of MENU is code. MENU is related to FOOD ITEM through this relationship:
each MENU may contain one or more FOOD ITEMs, and each FOOD ITEM must be listed on
one and only one MENU. The UID of FOOD ITEM is a barred UID using its attribute number.
Add appropriate attributes to the other entities and be ready to defend your choices..
2. Define the following terms, provide an example of each, and indic.pdfchughakshit42
2. Define the following terms, provide an example of each, and indicate why they are important
to leadership in health care management. A) Humbitious B) Emotional Intelligence C) #MeToo
D) Innovation E) Pacesetting leadership style.
1What did you do best in your undergraduate studies Have you ever.pdfchughakshit42
1
What did you do best in your undergraduate studies? Have you ever had an interdisciplinary
learning experience? If so, what impressed or interested you?
2
What knowledge and skills have you learned by participating in a class, such as an undergraduate
class, that is relevant to the major you are applying for? What do you think will help you succeed
in applying for the major? Please make a summary from the aspects of professional knowledge,
research methods, skills tools, etc.
Course 1
TitleFoundation of Finance (90/100)
Content of the course and your learning focus
Why are you impressed
Your Achievements
Course 2
TitleInvestment Analysis (86/100)
Content of the course and your learning focus
Why are you impressed
Your Achievements
Course3
TitleFinancial Decision Making (92/100)
Content of the course and your learning focus
Why are you impressed
Your Achievements
3
Please list any project activities you have participated in; certain experimental research projects;
or some kind of academic competition; (what research experience do you have related to the
major you are aiming to apply for? And can this experience prove your learning and research
ability to the university? Did you encounter any academic difficulties in your research, how did
you overcome them, or how did you conduct your research? Please mainly describe what you
have done and achieved. Please highlight the professionalism and depth of the activity, please
note that what you have done reflects the quality characteristics of your study target major)
Academic Programs 1
Situation: Project name, purpose, specific academic fields: AIA GROUP LIMITED (HONG
KONG STUDY TOUR) 2019.07-2019.08
Task: Academic key points and what you need to accomplish
Participated in the planning and promotion of insurance products in AIA Group Limited, and
cooperated with team members to design product recommendation advertisements, which won
the second place Participated in a business case analysis competition at the University of Hong
Kong: Why Samsung is successful. Analyzedthe industry competitiveness of the company by
means of SWOT and Porter's Five Forces Model within three hoursParticipated in writing
analysis reports on the development of Samsung products, marketing strategies and enterprise
competitiveness; made PowerPoint independently and participated in presentation of the results
Action: The obstacles you encounter, your academic understanding and practical operation
Result: Your results
Thinking & Reflection: What kind of progress, new ideas and reflections you have generated
throughout the process:
Academic Programs 2
Situation: Project name, purpose, specific academic fields:
Task: Academic key points and what you need to accomplish
Action: The obstacles you encounter, your academic understanding and practical operation
Result: Your results
Thinking & Reflection: What kind of progress, new ideas and reflections you have generated
throughout the process:
4
What has helped you most in your ac.
2. All the statements below are incorrect statements. Briefly explai.pdfchughakshit42
2. All the statements below are incorrect statements. Briefly explain why each one is incorrect, or
what wording changes makes it a correct statement
2-1. Theoretical capacity is always more than the effective capacity of a resource or resource
pool
2-2. Unit load refers to the maximum amount of time that a resource can allocate to each flow
unit to meet the demand
2-3. Flow time of a step in a process is equal to the activity time of that step
2-4. Increasing the marketing efforts to attract more customers can be a solution to address
internal bottleneck of a process
2-5. External bottleneck will lead to overloaded resources in a process
2-6. Throughput is never less than the effective capacity of a process
2-7. Job shop is a process architecture appropriate for manufacturing highly standardized large
volume of products
2-8 A business which stands on the operational frontier of its product attributes, is a business that
offer the best on all of the 4 product attributes as compared to its competitors
2-9 Operations Management is about the transformation of inputs into outputs of the processes,
and is about techniques to reduce inventory, throughput, and Flow Time
2-10 Extra-processing refers to producing more than what is needed
2-11 When a flight gate is changed in the last moment and you have to walk to a new gate to
catch your flight, the type of waste incurred is wait
2-12 Wastes must be avoided at any price, as they are costly for a business
2-13 The path with the smallest number of resources is taking the longest to complete, and
therefore is called the Critical Path
2-14 Buffer is an input to a process
2-15 Littles Law includes a relation between the flow unit, throughput, and inventory.
14. ila 16. y�zyllarda, talyan bankaclar finansal yeniliklerde lid.pdfchughakshit42
14. ila 16. yzyllarda, "talyan bankaclar" finansal yeniliklerde liderdi. Lombard (Kuzey talya)
bankacl nasl alt ve neden modern finansal uygulamalarn gelitirilmesinde nemli bir adm olarak
grlyor? belirli zayflklarndan herhangi birini tanmladnz m?.
15. Compare and contrast several characteristics of a growth stock a.pdfchughakshit42
15. Compare and contrast several characteristics of a growth stock and a value stock, including,
but not limited to, the company's current income levels and growth expectations, amount of
current dividends, and timing of cash flows generated by the company..
12. Ethical standard plays an important role in research. Which of t.pdfchughakshit42
12. Ethical standard plays an important role in research. Which of this do you think most affects
research data quality? A. Invading the privacy of participants B. Providing adequate training for
data collectors C. Choosing a census rather than a sample D. Bias in research design.
13. A clear research design in any project need to be set well. Whic.pdfchughakshit42
13. A clear research design in any project need to be set well. Which of the criteria that will
contributes to upholding the moral standard of a carefully thought and carried out research
design?
A. Obtaining participant consent
B. Using appropriate analytical techniques
C. Avoiding personal bias in selecting a sample
D. Defining concepts and constructs.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Normal Labour/ Stages of Labour/ Mechanism of LabourWasim Ak
Normal labor is also termed spontaneous labor, defined as the natural physiological process through which the fetus, placenta, and membranes are expelled from the uterus through the birth canal at term (37 to 42 weeks
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
2. LightValue enumWrite a simple Enum named LightValue, which list.pdf
1. 2. LightValue enum
Write a simple Enum named LightValue, which lists the phases a particular stoplight lane may
be in. These states should include GREEN, RED, and LEFT_SIGNAL (we are considering
yellow to be part of green). Each TwoWayRoad instance (defined below) will have its own
LightValue, which should correspond to the following rules:
GREEN indicates that the right and middle lanes may proceed, but the left lane cannot (for both
directions).
RED indicates that no lane may proceed (for both directions).
LEFT_SIGNAL indicates that left can proceed, but the right and middle lanes cannot (for both
directions).
Cars in a particular lane may proceed (dequeue one car per time interval) when it is their turn to
go, according to the rules above. If you still need help with Java Enum types, you can read about
them in this Java tutorial.
3. Vehicle Class
Write a fully documented class named Vehicle. This class represents a car which passes through
the intersection. Each instance must contain the serialId (the first car to arrive at the intersection
is serialId 1, the second car to arrive is serialId 2, the n'th car to arrive will have serialId >n) and
the time it arrived (stored as an int). The car must be initialized with a serialId and the time it
arrived. The serial counter is static and stores the number of vehicles that have arrived at the
intersection so far. It is the only variable that is modifiable.
The Vehicle class itself is actually immutable. This means once it has been constructed, no data
within the instance can be changed (the static serialCounter can and should be incremented on
each constructor call). From the UML diagram, note that the public constructor takes all the
member variables as arguments. Data can still be read via the getter methods.
private static int serialCounter = 0
private int serialId
private int timeArrived
public Vehicle(int initTimeArrived)
Brief:
Default Constructor. You should automatically increment the serialCounter, and set the serialId
to its new value.
Parameters:
initTimeArrived
Time the vehicle arrived at the intersection.
2. Preconditions:
initTimeArrived > 0.
Throws:
IllegalArgumentException
If initTimeArrived 0.
4. VehicleQueue class
Lanes in our simulator will be modelled as a Queue of Vehicles. You may implement a Queue of
vehicles however you like, and are encouraged to use any Java API class you prefer. Remember
that the VehicleQueue class must implement the following methods in order to comply with the
Queue ADT:
void enqueue(Vehicle v)
Vehicle dequeue()
int size()
boolean isEmpty()
Note: If you decide to use a Java API class to implement VehicleQueue, you must use
inheritance (extend a Java API class) to simplify the class definition.
5. TwoWayRoad Class
Write a fully documented class called TwoWayRoad that represents one of the roads in our
intersection. Each road it bi-directional, with each direction having three lanes - a left turn lane, a
middle lane, and a right turn lane. Lanes, modelled by VehicleQueues, hold the vehicles before
they pass through the intersection. These lanes will be stored in a two dimensional array - the
first index indicates the direction of travel on the road, and the second index indicates the lane on
the road. In order to access a specific direction, you should use the constants FORWARD_WAY
and BACKWARD_WAY to access the directions of the road. In order to access specific lanes in
a particular direction, you should use the second dimension of the array, accessed by the
consants LEFT_LANE, MIDDLE_LANE, RIGHT_LANE. Your TwoWayRoad class must be
able to check whether any of the lanes in the road have Vehicle objects in them by using the
boolean isEmpty(int wayIndex, int laneIndex) method. It should also be able to add Vehicle
objects to the lanes using the void enqueueVehicle(int wayIndex, int laneIndex, Vehicle vehicle)
method. Furthermore, you should allow vehicles to pass through the intersection, adding the
Vehicles that have been dequeued to an array to returned to the caller.
Brief:
public final int FORWARD_WAY = 0;
public final int BACKWARD_WAY = 1;
public final int NUM_WAYS = 2;
public final int LEFT_LANE = 0;
3. public final int MIDDLE_LANE = 1;
public final int RIGHT_LANE = 2;
public final int NUM_LANES = 3;
private String name
private int greenTime
The maximum total number of steps this road can be active (this number is inclusive of the
leftSignalGreenTime).
private int leftSignalGreenTime
The number of steps this road remains in the LEFT_SIGNAL state.
Should be initialized to 1.0/NUM_LANES * greenTime in the constructor.
private VehicleQueue lanes[NUM_WAYS][NUM_LANES]
private LightValue lightValue
public TwoWayRoad(String initName, int initGreenTime)
Brief:
Default Constructor. You should automatically initialize the array and all of its member objects,
as well as initializing leftSignalGreenTime to 1.0/NUM_LANES * initGreenTime.
Parameters:
initName
The name of the road.
initGreenTime
The amount of time that the light will be active for this particular road. This is the total of the
time the light should display green for cars going forward/turning right, as well as for cars going
left.
Preconditions:
initGreenTime > 0.
Postconditions:
This road is initialized with all lanes initialized to empty queues, and all instance variables
initialized.
Throws:
IllegalArgumentException
If initGreenTime 0 or initName=null.
public Vehicle[] proceed(int timerVal)
Brief:
Executes the passage of time in the simulation. The timerVal represents the current value of a
countdown timer counting down total green time steps. The light should be in state GREEN any
time the timerval is greater than leftSignalGreenTime. When timerVal is less than or equal to
4. leftSignalGreenTime, the light should change to LEFT_SIGNAL. After the execution of
timerVal == 1, or if there are no vehicles left the light should change state to RED.
Parameters:
timerVal
The current timer value, determines the state of the light.
Preconditions:
The TwoWayRoad object should be instantiated.
Returns:
An array of Vehicles that has been dequeued during this time step.
Postconditions:
Any Vehicles that should have been dequeued during this time step should be dequeued and
placed in the return array.
Throws:
IllegalArgumentException
If timerval 0.
public void enqueueVehicle(int wayIndex, int laneIndex, Vehicle vehicle)
Brief:
Enqueues a vehicle into a the specified lane.
Parameters:
wayIndex
The direction the car is going in.
laneIndex
The lane the car arrives in.
vehicle
The vehicle to enqueue; must not be null.
Preconditions:
The TwoWayRoad object should be instantiated.
Postconditions:
Given that the vehicle specified was not null, and the position given was not invalid (and no
exception was thrown), the vehicle should be added to the end of the proper queue.
Throws:
IllegalArgumentException
If wayIndex > 1 || wayIndex < 0 || laneIndex < 0 || laneIndex > 2 or vehicle==null
.
public boolean isLaneEmpty(int wayIndex, int laneIndex)
Brief:
5. Checks if a specified lane is empty.
Parameters:
wayIndex
The direction of the lane.
laneIndex
The index of the lane to check.
Preconditions:
The TwoWayRoad object should be instantiated.
Returns:
true if the lane is empty, else false.
Postconditions:
The TwoWayRoad object should remain unchanged
Throws:
IllegalArgumentException
If wayIndex > 1 || wayIndex < 0 || laneIndex < 0 || laneIndex > 2.
6. Intersection class
Write a fully documented class named Intersection. This class represents a crossing of two or
more roads at a stop light in our simulation. The class consists of an array of TwoWayRoad
objects representing the crossing roads, as well as a countdown timer and a light index.
Intersection must contain the following private member variables: roads (TwoWayRoad[]),
lightIndex (int), and countdownTimer (int). The Intersection class must also feature the
following public methods: void timeStep(), and void enqueueVehicle(int roadIndex, int
wayIndex, int laneIndex), as well as a display() method which prints the intersection to the
terminal.
private TwoWayRoad[] roads
Array of roads which cross at this intersection.
private int lightIndex
Indicates the road in roads with the active light (either green or left turn signal).
private int countdownTimer
Tracks the remaining time steps available for the road currently indicated by lightIndex.
public Intersection(TwoWayRoads[] initRoads)
Brief:
Constructor which initializes the roads array.
Parameters:
initRoads
Array of roads to be used by this intersection.
6. Preconditions:
initRoads is not null.
Length of initRoadsis less than or equal to MAX_ROADS.
All indices of initRoads are not null.
Postconditions:
This object has been initialized to a Intersection object managing the roads array.
Throws:
IllegalArgumentException
If initRoads is null.
If any index of initRoads is null.
initRoads.length > MAX_ROADS.
public Vehicle[] timeStep()
Brief:
Performs a single iteration through the intersection. This method should apply all the logic
defined in this specification related to the passing of cars through the intersection and switching
the selected road (Note: LightValue changes for a particular road should be handled within the
TwoWayRoad class itself and not within this method). Please refer to the Simulation Procedure
section above for instructions on how to apply this procedure.
Postconditions:
The intersection has dequeued all lanes with a green light (if non-empty) and returned an array
containing the Vehicles.
Returns:
An array of Vehicles which have passed though the intersection during this time step.
public void enqueueVehicle(int roadIndex, int wayIndex, int laneIndex, Vehicle vehicle)
Brief:
Enqueues a vehicle onto a lane in the intersection.
Parameters:
roadIndex
Index of the road in roads which contains the lane to enqueue onto.
wayIndex
Index of the direction the vehicle is headed. Can either be TwoWayRoad.FORWARD or
TwoWayRoad.BACKWARD
laneIndex
Index of the lane on which the vehicle is to be enqueue. Can either be
TwoWayRoad.RIGHT_LANE, TwoWayRoad.MIDDLE_LANE, or
TwoWayRoad.LEFT_LANE.
7. vehicle
The Vehicle to enqueue onto the lane.
Preconditions:
0 roadIndex < roads.length.
0 wayIndex < TwoWayRoad.NUM_WAYS.
0 laneIndex < TwoWayRoad.NUM_LANES.
vehicle != null.
Throws:
IllegalArgumentException
If vehicle is null.
If any of the index parameters above are not within the valid range..
public void display()
Brief:
Prints the intersection to the terminal in a neatly formatted manner. See the sample I/O for an
example of what this method should display.
7. IntersectionSimulator class
Write a fully documented class named IntersectionSimulator. This class represents the manager
of the simulation -- it does the heavy lifting, per se. The main function's responsibility is to get
the parameters for the simulation and pass them to the simulate() method, either by interactive
prompt or command line (See below).
public static void main(String args[])
Start for application, asks user for following values: simulationTime (int), arrivalProbability
(double), numRoads (int), a name for each road, and a "green" time for each road. This method
also parses command line for these args. If args.length < 5, the above is read in at execution
time. Otherwise, refer to the end of this document on how to parse the command line arguments.
public static void simulate(int simulationTime, double arrivalProbability, String[] roadNames,
int[] maxGreenTimes):
This method does the actual simulation. Above, a Activity Diagram is presented to demonstrate
how the simulation works. This method actually implements the algorithm described by that
diagram, using Intersection, BooleanSourceHW4, and TwoWayRoad. Simulation Procedure The
primary simulation procedure should be contained within a static function called simulate ()
inside the Intersectionsimulator class. This method should begin by initializing the intersection
based on a few parameters (listed below), and enter a loop which executes the time steps. Your
program will simulate the arrival of vehicles on up to four roads of an intersection for a specified
simulation time. You may assume that each road has two traveling directions (forward and
8. backward), with each traveling direction having three lanes (a left turn lane, a middle lane, and a
right turn lane), for a total of 2 roads * 2 directions per road 3 lanes per direction = 12 lanes. The
simulation will take five parameters at the onset: 1. simulationtime (int): Indicates the desired
total simulation time. 2. arrivalprobability (double) : Indicates the probability that a vehicle will
arrive at any lane during a time step. 3. numRoads (int) : Indicates the number of two-way roads
that meet at this intersection. 4. names (string [ ]): An array of size numRoads indicating the
name of each road. 5. greentimes (int []): An array of size numRoads indicating the green time
for each road. Note: The two array parameters (names and greentimes) should be equal in size
and have corresponding indices (i.e. names [i] corresponds to a road having a green time of
geentimes [ i] ). Initialization Before the first time step, your program should create a new array
of TwowayRoads equal in size to the array parameters. A new TwowayRoad object should be
created at each index of this new array, initializing each new road with the name and greentime
at the corresponding index of the array parameters (names and greentimes, respectively). Once
this array has been created and initialized, it should be used to construct an Intersection instance,
which will be used to keep track of the light during simulation and allow vehicles to pass through
the intersection. Lastly, a BooleanSourceHw4 object should be created (initializing it's
probability member variable to arrivalprobability) which will be used to determine if vehicles
have arrived during simulation. During execution, the 'light' will be simulated using the
lightindex member variable of the Intersection instance. This variable indicates the index of the
road in the roads array which currently has the active light (the current active light may be in the
GREEN state or LEFT_TURN state, as described by the LightValue enum below). When the
Intersection instance is constructed, it initializes the lightindex member variable to 0 and the
countdownTimer to the greentime member variable of roads[lightindex]. After each time step,
the timer is decremented by 1. Once the timer reaches 0 , the lightindex is incremented, returning
back to 0 if it equals the size of the roads array (i.e. modular arithmetic), and the countdowntimer
is again set to roads [ lightindex]. This process repeats continually until the simulation ends.
Time Steps On each time step, the program should determine if a vehicle has arrived for each
lane in the intersection (all 12). This can be accomplished by calling the occursHw4 () method
on the BooleansourceHw4 object for each lane. If a vehicle has arrived (i.e. occursHW4 ()
returns true), the program should create a new vehicle object, initialize it's timeArrived member
variable to the current time step value, and enqueue the vehicle onto the appropriate lane. After
all lanes have been considered for arrival, roads [ lightindex] should pass vehicles through the
intersection - one vehicle per lane, but only if the lane is allowed to proceed (see the LightValue
enum below for more detail on the light rules). When a vehicle is dequeued from a lane, the
program should add the vehicle's wait time to the total wait time for the simulation, and
9. increment the number of cars passed through the intersection. The vehicle's wait time can be
calculated by subtracting it's arrivaltime from the current time step value. If all lanes are empty
after having been dequeued (or ignored if they were empty), then the program should preempt
the countdown timer and switch the light to the next road. Note: On any particular time step, a
maximum of 6 vehicles may be queued onto lanes of the intersection, and a maximum of 4
vehicles may pass through an intersection (if the lightValue is GREEN, then the right and middle
lanes can proceed in both directions, but the left lanes cannot). In other words, any lane can be
enqueued and dequeued only once on a given time step. A case you should consider is if a lane
of the road with the green light is empty at the beginning of the time step, and has an arrival
during the time step. If this happens, then the vehicle will be enqueued and dequeued from the
lane during the same time step, resulting in a wait time of zero (this is the equivalent of driving
through a green light without having to wait). After these operations have been completed, the
simulation should output the current state of the intersection to the user. This should include the
number of cars on each of the 12 lanes of the intersection, as well as their current wait times. In
addition, the current total wait time, total number of cars, and average wait time should be shown
in tabular form (please see the sample I/O for examples). The program now proceeds to the next
time step, repeating the process until the time step value is equal to simulationTime. Finalization
Once the time step counter reaches simulationtime, no more vehicles should arrive at the
intersection. The simulation should proceed as normal until all lanes have been cleared and the
intersection is empty. Once the intersection is clear of vehicles, the simulation should end and
the program should display the results to the user. The output parameters should include the total
wait time by all vehicles, the total number of vehicles passing through the intersection, and the
average wait time for vehicles during the simulation.
Once the time step counter reaches simulationtime, no more vehicles should arrive at the
intersection. The simulation should proceed as normal until all lanes have been cleared and the
intersection is empty. Once the intersection is clear of vehicles, the simulation should end and
the program should display the results to the user. The output parameters should include the total
wait time by all vehicles, the total number of vehicles passing through the intersection, and the
average wait time for vehicles during the simulation. The entire procedure is summarized by the
following Activity Diagram:
1. BooleansourceHW4 class (Provided as attachment to the specification) A class called
BooleanSourceHw4 which abstracts a random occurrence generator. This class should be
constructed with an initial arrival probability (0.0< probability 1.0) which represents the
likelihood that a vehicle will arrive at any particular lane at the beginning of each time step. This
10. method should also contain a single method, occursHW4 () which returns true if a vehicle arrives
and false it does not. - private double probability - public BooleanSourceHW4(double
initProbability) - Brief: - Constructor which initializes the probability to the indicated parameter.
- Parameters: - initProbability - Probability used to construct this BooleanSourceHw4 object. The
probability should be greater than 0 and less than or equal to 1 . - Preconditions: - 0<
initProbability 1. - Throws: - IllegalargumentException - If initProbability 0 or initProbability
>1. - NOTE: - This class works with hw4randomNumbers.txt and hw4randomFlags.txt text files
that are attached to the homework specification. - public boolean occursHW() - Brief: - Method
which returns true with the probability indicated by the member variable probability. -
Preconditions: - probability is a valid probability ( 0< probability 1 ). - Returns: - Boolean value
indicating whether an event has occurred or not. - Note: - This method will utilize a saved
random number to generate the random occurrence.
// Comment in green, input in red, output in black Sample I/O: Welcome to Intersectionsimulator
2021 Input the simulation time: 6 Input the arrival probability: 0.2// chance of car entering a lane,
for all lanes. Input number of streets: 2 Input Street 1 name: Route 216 // must be unique names
& not the empty string Input Street 2 name: Route 216// on duplicate detected, re-prompt for
name Duplicate Detected. Input Street 2 name: 320 Road Input max green time for Route 216: 4
Input max green time for 320 Road: 3 Starting Simulation... Time step: 1 Green Light for Route
216 . // Select first road at start. Timer =4// Initialize timer to max green time for road.
ARRIVING CARS : Car[001] entered Route 216, going FORWARD in LEFT lane. Car[002]
entered Route 216, going BACKWARD in MIDDLE lane. Car[003] entered 320 Road, going
FORWARD in RIGHT lane. PASSING CARS: // Car[001] can't pass since 216-FORWARD-
LEFT has red light (x). Car[002] passes through. Wait time of 0 . // Car[003] can't pass since
320-FORWARD-RIGHT has red light (x).