Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i am having difficulty with a c+

Status
Not open for further replies.

JadeProg

Programmer
Mar 21, 2001
3
US
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.
 
Can you at least show us what code you have attempted to write already, and tell us what specific problems you are having to understand your "Assignment" Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
well, it's like, i have to code for a standard queue and a standard stack. and i have most of the header file for the elevator class. i know what it's suppossed to do, i just don't know where to start, period. i know that isn't much to give help to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top