another elevator simulation problem

haii...last time i ask about elevator problem and got the solution...for this time i have another problem regarding the same simulation but just need improvement...so here it goes...

i have to create :

1. building with 4 elevator and 4 floor. (i managed to create 4 floor but not elevator)

2. the elevators must be able to track which floor button is being pressed and avoid opening two lifts on the same floor at the same time. (big problem...i dont know how to make it)

3. i want to make the elevator selectable, where user put the value of elevator that need to run. (maximum is 4 elevators)

can i post my code in mediafire and put the link here so that other member can look the code and give me some advice..?
Ok I did not see your older post, ao are you actualy drawing out the elevato and floors, like with Win32, or OpenGL, or are you just using numbers to tell you when they are, like "Elevator is on floor 4"?
the output only show text...just like you have mention above...let me give some example...

elevator at rest floor 1
moving up
arrive at floor 2
person summon elevator on floor 1
going down
arrive at floor 1
.
.
.
.
.
.
.
end of simulation...

that how the output goes...what make me headache is the 3 problem that i mention earlier...do you need the code..? i can send it to your email...and you can give me advice which part of the code need some improvise...
Is this what you wanted?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>// Used for the output
#include <cstdlib>// Used for clearing the screen
using namespace std;// We want to specify the standard namespace

const int TopFloor = 4;// The top floor in your program

// This is the start of our program
int main() {// Look up
    int DesiredFloor = 1;// The floor that the user wants to go to
    int CurrentFloor = 1;// The floor that the user is already on
    while(true) {// We will always be looping
        cout << "You are on floor " << CurrentFloor// Output the floor that the user is on
             << ", what floor would you like to goto: ";// Ask what floor the user wants to go to
        cin >> DesiredFloor;// Put that value into the DesiredFloor
        if((DesiredFloor < 1) || (DesiredFloor > TopFloor)) {// Make sure that value is allowed
            cout << "That floor in not available!" << endl;// Report the error
            system("pause");// Wait for the user to see what is on the screen
            break;// Leave the loop
        }// End of If statement
        if(DesiredFloor < CurrentFloor) {// If we need to go down
            while(DesiredFloor != CurrentFloor) {// while we are not on that floor
                cout << "Going Down" << endl;// We are going down
                CurrentFloor--;// Subtract one from the current floor
                cout << "We are on floor " << CurrentFloor << endl;// Say what floor we are on
            }// End of while Loop
        } else if(DesiredFloor > CurrentFloor) {// If we need to go up
            while(DesiredFloor != CurrentFloor) {// while we are not on that floor
                cout << "Going Up" << endl;// We are going down
                CurrentFloor++;// Add one to the current floor
                cout << "We are on floor " << CurrentFloor << endl;// Say what floor we are on
            }// End of while Loop
        } else {// If we are already on thae floor that the user wants to be on
            cout << "We are already there" << endl;
        }// End of If statement
        cout << "At rest on floor " << CurrentFloor << endl;// Say what floor we are on
        system("pause");// Wait for the user to see what is on the screen
        system("cls");// Clear the screen
    }// End of While loop
}// End of the program 
the code that you give me is working perfect for the floor...but the building have 4 elevator and 4 floor and some other classes {door(open/close), button(floorbutton, elevatorbutton), floorlight, passenger(appear at random time and random floor using scheduler), clock(to show simulation runtime), and scheduler(schedule passenger appear at random time and random floor)}...i will try to implement your code in my code...i will give the result later...by the way, thanks a lot for helping me with the code...
That sound INCREDIBLY daunting, and a lot like a homework assignment, HAVE FUN!!!
yahhh...hahaha!!! incredibly daunting!!! it's my senior homework...i just try to do this program because it's going to be my homework next year...so have to prepare early...hahahaha!!! my senior also cant do this thing...and it's quite challenging for him...
Topic archived. No new replies allowed.