For statement not working

I have to write an elevator simulation for an assignment using classes and what not and I'm having a bit of trouble. I've narrowed it down to my "for" statement in one of the classes isn't going up or down to the next level.
The real problem occurs here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void elevator::godown( int lowerfloor )
{
    cout << "Starting at fl0or #" << currentfloor << endl;
    int i = currentfloor;
    for ( currentfloor; i == lowerfloor; i --)
        cout << "Going down -- now at floor #" << i << endl;
    
    cout << "Welcome to floor #" << i;
    
}

void elevator::goup( int higherfloor )
{
    cout << "Starting at flo0r #" << currentfloor << endl;
    int x = 0;
    for ( x = currentfloor; x == higherfloor; x++){
        cout << "Going up -- now at floor #" << x << endl;}

    cout << "Welcome to floor #" << x;
    
}


whatever floor I put for the current floor it just outputs:

Starting at flo0r #3
Welcome to floor #3

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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
 //include library
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

static const int TOP_FLOOR = 15;
static const int BOT_FLOOR = 1;

class elevator
{
public:
    elevator();
    elevator (int);
    int elevator_number;
    void request( int );
    int get_current_floor();
    int currentfloor;
    
private:
    void godown( int );
    void goup ( int );
    int startfloor;
    int previousfloor;
    int nextfloor;
    
};

elevator::elevator()
{
    int currentfloor = 0;
    int startfloor = 0;
    int nextfloor = 0;
    
}

elevator::elevator(int startingfloor)
{
    
    startfloor = startingfloor;
}



int elevator::get_current_floor()
{
    return currentfloor;
}

void elevator::request ( int newFloor)
{
    if (currentfloor == 0)
        currentfloor = startfloor;
    nextfloor = newFloor;
    
    if (newFloor > 15 || newFloor < 1)
        cout << "Error: Invalid Floor Number" << endl;
    
     else if (newFloor == currentfloor)
         cout << "You're already on that floor" << endl;
    
    
   else  if (newFloor > currentfloor)
        elevator::goup(newFloor);
    
   else  if (newFloor < currentfloor)
        elevator::godown(newFloor);
    
    
   
}

void elevator::godown( int lowerfloor )
{
    cout << "Starting at fl0or #" << currentfloor << endl;
    int i = currentfloor;
    for ( currentfloor; i == lowerfloor; i --)
        cout << "Going down -- now at floor #" << i << endl;
    
    cout << "Welcome to floor #" << i;
    
}

void elevator::goup( int higherfloor )
{
    cout << "Starting at flo0r #" << currentfloor << endl;
    int x = 0;
    for ( x = currentfloor; x == higherfloor; x++){
        cout << "Going up -- now at floor #" << x << endl;}

    cout << "Welcome to floor #" << x;
    
}

 
 
 

int main()
{
  
    elevator elevator1(1);
    elevator elevator2 (3);
    
    elevator2.request(11);
    
    
    
    
    
    return 0;
};
Look at the condition in your loop. Explain its logic.
Topic archived. No new replies allowed.