Thread: Elevator Function confusion

  1. #1
    High school loser
    Join Date
    Dec 2004

    Question 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.

  2. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    What are you confused about? What functioncs are? Try this tutorial for some basic help on functions:

    If your question is more indepth about what you need to do with functions for this project, you'll need to post a little more information about the project, and what your ideas about it are so far. That way people can help you figure out what the answer is.

    Good luck!

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    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.

  4. #4
    High school loser
    Join Date
    Dec 2004
    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
    Write log heading
    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
    Load People on Floor
    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
    Increment Arrival Time [note: this is how a resting elevator
    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?

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    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


    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.
    Last edited by CornedBee; 12-16-2004 at 01:58 AM.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    High school loser
    Join Date
    Dec 2004
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Terrible confusion with time variables
    By LowlyIntern in forum C++ Programming
    Replies: 12
    Last Post: 08-01-2008, 07:23 AM
  2. C++ Classes: Use, Misuse...Confusion.
    By Snorpy_Py in forum C++ Programming
    Replies: 4
    Last Post: 10-23-2006, 01:46 AM
  3. for loop confusion
    By Enges in forum C++ Programming
    Replies: 6
    Last Post: 04-26-2006, 08:21 AM
  4. Server-net newbie confusion
    By geek@02 in forum Windows Programming
    Replies: 1
    Last Post: 04-28-2005, 02:08 AM
  5. confusion with increment and decrement operators
    By cBegginer in forum C Programming
    Replies: 6
    Last Post: 03-19-2005, 03:45 PM