# Elevator Function confusion

• 12-15-2004
applescruff
Elevator Function confusion
My teacher assigned us a group project to make a a concept model of an elevator that we supposedly designed earlier. We understand the basis of the project, but we have no idea what to do with the functions. The project description and psuedocode are rather long, so I won't post them unless someone shows an interest in seeing it.
Please help. All of us are very confused and the teacher refuses to help because he assumes we absorbed the knowledge through ESP or something.
• 12-15-2004
kermi3
What are you confused about? What functioncs are? Try this tutorial for some basic help on functions:

http://www.cprogramming.com/tutorial/lesson4.html

Good luck!
• 12-15-2004
LuckY
Not to make you feel bad, but you seem to think we could determine what problems you're having through ESP or something. ;P
You need to specify what you're actually having a problem with. Are you talking about an elevator as in a box you get in and go up and down in or an elevator algorithm used to read a disk? What exactly do you need to do and what exactly are you unable to do?

Just fill in some of the details and you'll have lots of answers immediately.
• 12-15-2004
applescruff
Sorry about the lack of details. Here's what the teacher supplied us with. There's rather a lot for a forum, but oh well:

Elevator Simulation Project
You are an engineer designing an elevator system for a two-story building.
Before you begin construction, your client asks you to create a simulation of
the performance of your design. The client specifies that the elevator begins
the day at rest on the first floor. He says, "let's assume that every twenty
time periods a scheduler randomly decides to populate each floor in the
interval of 5 to 20 time periods into the future." At the scheduled time the
person mysteriously arrives on the specified floor and calls the elevator
(should there already be someone waiting on the floor, the arrival time of the
new person is delayed until the floor is empty). The elevator takes five time
periods to move between floors. It has a capacity of one person. During the
time in which it arrives on a floor, it first unloads, loads, and begins its
trip to the next floor. To review your design, the client requires a detailed
report of the status during each time period. This report must include the
elevator status: full/empty, destination (floor 1, floor 2, or resting) and
arrival time; floor status: person waiting/vacant, scheduled arrival time of
next person. The simulation is to run for 100 time periods.

He also supplied some psuedocode:

Variable list
int Clock
enum elevator status {FULL, EMPTY}
int Elevator destination
int Elevator arrival time at the destination
bool Person waiting floor 1
bool Perosn waiting floor 2
int Scheduled person creation time floor 1
int Scheduled person creation time floor 2

Declare and initialize variables
Open file
While time is less that 101
Do what you need to do each time period
Every 20 time periods
Generate Person creation times (floor 1)
Generate Person creation times (floor 2)
If person creation time occurs
Do Elevator Stuff
if Elevator Arrived on floor
if full
if person is waiting on this floor
Set Destination
Set Arrival Time
else if person waiting on other floor
Set Destination
Set Arrival Time
else
Increment Arrival Time [note: this is how a resting elevator
occurs]
Write Report Line
Increment clock
Close file.

He said we needed to make each verb into a function. We figure that's 12 functions: OpenFile, LogHeading, GeneratePeopleTimes1, GeneratePeopleTimes2, Load, Unload, SetDestination, SetArrivalTime, IncrementArrivalTime, IncrementTime, WriteLog, CloseFile. We're supposed to do code stubs for these functions, but we're not sure how to make these functions link up and work together.

Is that too much detail?
• 12-16-2004
CornedBee
Quote:

Is that too much detail?
Not at all, but it sadly is not enough effort from you. What exactly is your problem? What do you mean by "link up and work together"?

Functions call each other by name, so if you have

void func();

you can call it from another function using

func();

Oh, and some of those functions you identified already exist. OpenFile and CloseFile exist in the <iostream> library, as ofstream::ofstream and ofstream::~ofstream, or ofstream::open and ofstream::close.
• 12-16-2004
applescruff
Ah. Something just clicked in my thick little head. I think we can do it now. Thanks for your help, CornedBee! You are a lifesaver.