Question
#include #include using namespace std; class Elevator { private: int elNum; // elevator number int currentFloor; // current floor int highestFloor; // highest floor public:
#include
class Elevator { private: int elNum; // elevator number int currentFloor; // current floor int highestFloor; // highest floor public: Elevator(int = 1, int = 1, int = 15); // constructor void request(int); }; //constructor function Elevator::Elevator(int e, int c, int h) { elNum = e; currentFloor = c; highestFloor = h; }
void Elevator::request(int) { int const maxFloor = 15;
if(int i<1 || i>15) { return; } else if(
Complete the following class by including functions corresponding to the two prototypes listed in the declaration section:
In this definition, the data member elNum is used to store the elevators number, the data member currentFloor is used to store the elevators current floor position, and the data member highestFloor is used to store the highest floor the elevator can reach. The constructor should allow initialization of an objects three data members with the data passed to the constructor when an Elevator object is instantiated. The request function should code the following algorithm: If a request is made for a nonexistent floor, a floor higher than the topmost floor, or the current floor Do nothing If the request is for a floor above the current floor Display the current floor number While not at the designated floor Increment the floor number Display the new floor number EndWhile Display the ending floor number Else // the request must be for a floor below the current floor Display the current floor number While not at the designated floor Decrement the floor number Display the new floor number EndWhile Display the ending floor number EndIf b. Include the class written for Exercise 3a in a complete program, and verify that all member functions work correctly
cant figure out the request function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started