i am having difficulty with a c++ program involving stacks and queues. it is an elevator simulator.
any help would be greatly appreciated. i have an exe that does the necessary output given by my instructor. though an exe file doesn't help at all except with the output since all ouput is to a file. here is what i was given:
This assignment is designed to give you practice using linked lists, stacks, and queues in a real simulation. You will be simulating a set of elevators with people getting on and off. There are three (3) elevators, each covering ten (10) floors. Each elevator can hold up to seven (7) people. At each floor, up to 2 people can be added at each step of the simulation but no more than five people can be waiting (the idea being that if more than five people are waiting someone would get fed up and take the stairs). For this simulation, we will not consider the passengers' destination floor. Run the simulation for 30 steps. After 30 steps, continue the simulation until there are no passengers on any of the elevators. Below is an outline of how the simulation works
1. For each pass of the simulation:
A. If in the first 30 steps of the simulation update the people waiting at the floors: (add a random number of people (0, 1 or 2) at each floor. Make sure there are not more than five (5) people waiting at a floor at any one time. People added should be represented as an integer equal to the simulation step they were created on).
B. For each elevator
a. Update the elevator placement (if there are no people waiting at a floor and no one on the elevator, the floor should be skipped. If the elevator reaches the top or bottom, it should change direction. If there are no people waiting on any of the floors the elevator should stay on the current floor).
b. Let a random number of passengers out, but not more than 5 people (or else the doors will close on them!).
c. Load passengers: as many on the floor as possible, up to the maximum passenger load.
C. Print out the status of the elevators (it's current floor, the passenger ID'S (step generated) and number of current passengers) and floors (floor number, the passenger's ID (step generated) and the number of passengers waiting).
Hint: to print out the passengers (either on the elevator or waiting on the floor) you will need to Pop/QDelete them. You might want to make a copy of the Stack/Queue so that the original data is not lost.
any help would be greatly appreciated. i have an exe that does the necessary output given by my instructor. though an exe file doesn't help at all except with the output since all ouput is to a file. here is what i was given:
This assignment is designed to give you practice using linked lists, stacks, and queues in a real simulation. You will be simulating a set of elevators with people getting on and off. There are three (3) elevators, each covering ten (10) floors. Each elevator can hold up to seven (7) people. At each floor, up to 2 people can be added at each step of the simulation but no more than five people can be waiting (the idea being that if more than five people are waiting someone would get fed up and take the stairs). For this simulation, we will not consider the passengers' destination floor. Run the simulation for 30 steps. After 30 steps, continue the simulation until there are no passengers on any of the elevators. Below is an outline of how the simulation works
1. For each pass of the simulation:
A. If in the first 30 steps of the simulation update the people waiting at the floors: (add a random number of people (0, 1 or 2) at each floor. Make sure there are not more than five (5) people waiting at a floor at any one time. People added should be represented as an integer equal to the simulation step they were created on).
B. For each elevator
a. Update the elevator placement (if there are no people waiting at a floor and no one on the elevator, the floor should be skipped. If the elevator reaches the top or bottom, it should change direction. If there are no people waiting on any of the floors the elevator should stay on the current floor).
b. Let a random number of passengers out, but not more than 5 people (or else the doors will close on them!).
c. Load passengers: as many on the floor as possible, up to the maximum passenger load.
C. Print out the status of the elevators (it's current floor, the passenger ID'S (step generated) and number of current passengers) and floors (floor number, the passenger's ID (step generated) and the number of passengers waiting).
Hint: to print out the passengers (either on the elevator or waiting on the floor) you will need to Pop/QDelete them. You might want to make a copy of the Stack/Queue so that the original data is not lost.