Implement a VehicleQueue that records vehicle events waiting on one approach to the traffic intersection. The class must preserve first-in, first-out behavior, report both vehicle count and physical queue length, and keep queue storage separate from vehicle creation and signal-control policy.
VehicleQueue
One VehicleQueue type should support north, south, east, and west approaches through separate instances. A VehicleFactory or FlyweightVehicleFactory creates vehicle descriptions; it does not own the queue. Each queued event retains occurrence-specific information such as identifier and arrival time even when several events share one immutable vehicle-type flyweight.
VehicleFactory
FlyweightVehicleFactory
ArrayDeque
std::deque
std::queue
enter()
leave()
getSize()
getLength()
list()
Submit the queue class, any small interface or event type required by the design, and focused tests. Include a short explanation of collection choice, factory ownership, empty-queue behavior, and how deterministic arrival tests are achieved. Your response may use Java or C++, but it must be internally consistent and compilable with a current language version.
The solution is evaluated for FIFO correctness, explicit ownership, separation of responsibilities, meaningful validation, deterministic tests, and clear handling of empty queues. A solution that only stores strings, clears an entire direction at once, hides random creation in global state, or exposes its mutable collection does not satisfy the exercise.
Type your answer in the text area below. Click Submit to send the response to the results page. Review the requirements and tests before submitting.