Question: (Program) a. Complete the following class by including functions corresponding to the two prototypes listed in the declaration section: class Elevator { private: int elNum;

(Program) a. Complete the following class by including functions corresponding to the two prototypes listed in the declaration section:

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); };

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

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!