Object-Oriented Elevator...
I'm an OOP class and have been having numerous problems compiling an elevator simulator program. Basically, the only major requirement is currentFloor must be a private data member, the program has to say all that stuff I put in it to say with the floors going up and down and such, and it must have separate implementation for the class. (I'm not sure if I did that or not, since I wasn't quite sure what it meant. I'll be happy if the program runs, though. That's what I'm shooting for right now.)
I don't really understand it that well and more or less went through and made random changes to the program repeatedly until the errors the compiler gave me went away one by one. (That's not how I should do it, I know. I'm not planning on becoming a programmer, though. I want to go into networking and be a network administrator someday. My university just thinks I need to have a ton of programming classes for some reason.)
After I was triumphantly making the last error disappear, it gave me new errors that Borland's site says are "usually caused by some mix-up between the intended project type and the actual project type." I don't use Visual Studio or anything that lets you choose a project type. I code straight into TextPad and then compile with Borland. So I'm really confused as to what I can do to fix it.
#include [iostream.h] //I replaced the regular brackets because LJ doesn't like them.
class Elevator
{
private:
int currentFloor;
public:
void request (currentFloor);
~Elevator ( );
Elevator (int Floor)
{Floor=currentFloor;
currentFloor=1;}
};
void request (currentFloor)
{
int requestedFloor;
cout << "Please enter the floor number you wish to go to: ";
cin >> requestedFloor;
cout << "Starting at floor " << currentFloor;
while (currentFloor != requestedFloor)
{
if (currentFloor > requestedFloor)
{
cout << "Going Down - now at floor " << currentFloor;
}
else
{
cout << "Going Up - now at floor " << currentFloor;
}
}
if (currentFloor = requestedFloor)
{
cout << "Stopping at floor " << currentFloor;
}
return;
}
void main ()
{
int Floor;
Elevator Diane(1);
Diane.request(Floor);
}
I don't really understand it that well and more or less went through and made random changes to the program repeatedly until the errors the compiler gave me went away one by one. (That's not how I should do it, I know. I'm not planning on becoming a programmer, though. I want to go into networking and be a network administrator someday. My university just thinks I need to have a ton of programming classes for some reason.)
After I was triumphantly making the last error disappear, it gave me new errors that Borland's site says are "usually caused by some mix-up between the intended project type and the actual project type." I don't use Visual Studio or anything that lets you choose a project type. I code straight into TextPad and then compile with Borland. So I'm really confused as to what I can do to fix it.
#include [iostream.h] //I replaced the regular brackets because LJ doesn't like them.
class Elevator
{
private:
int currentFloor;
public:
void request (currentFloor);
~Elevator ( );
Elevator (int Floor)
{Floor=currentFloor;
currentFloor=1;}
};
void request (currentFloor)
{
int requestedFloor;
cout << "Please enter the floor number you wish to go to: ";
cin >> requestedFloor;
cout << "Starting at floor " << currentFloor;
while (currentFloor != requestedFloor)
{
if (currentFloor > requestedFloor)
{
cout << "Going Down - now at floor " << currentFloor;
}
else
{
cout << "Going Up - now at floor " << currentFloor;
}
}
if (currentFloor = requestedFloor)
{
cout << "Stopping at floor " << currentFloor;
}
return;
}
void main ()
{
int Floor;
Elevator Diane(1);
Diane.request(Floor);
}
