Question: Write a C++ class to implement the elevator class defined below. Here is file Elevator.h (down- loadable off the class web pages) #ifndef #define ELEVATOR-H





Write a C++ class to implement the elevator class defined below. Here is file Elevator.h (down- loadable off the class web pages) #ifndef #define ELEVATOR-H ELEVATOR-H #define DEFAULT-FLOORS 5 #define TIME-BETWEEN-FLOORS 1000 /* in milliseconds, an integer */ namespace egre246 [ class Elevator f public enum action AT_FLOOR, STOPPED, MOVING_UP, MOVING_DOWN, DOOR OPENING,DOOR CLOSING; Elevator (int tineBetween-TIME-BETWEEN-FLOORS); // default name: "elevator #1" Elevator(std: :string name,bool inServ,int totalFloors, int currentFloor, int tineBetween TIME-BETWEEN-FLOORS) bool getInServiceO const; // returns if in service void setInService (bool) // sets inService std: :string getName ) const; void setName (std: :string); int getNumFloors() const; // returns total # of floors; ground floor-. 0 int getCurrFloor) const; // returns current floor int getTimeBetweenFloors) const; // returns timeBetweenFloors void setTimeBetweenFloors(int); // sets timeBetweenFloors; // must be > 0, if not, does nothing // door opening & closing requires TIME_BETWEEN_FLOORS 2 amount of time void openDoor // if elevator isn't moving, open the door & report action; // otherwise do nothing void closeDoor ; // if elevator isn't moving, close the door and report action; // otherwise do nothing void moveTo(int); // move to floor if argument is a legal floor, do nothing otherwise; // report action if moving up or down (once, see sample run); // report action when you pass each floor; report action when // elevator stops; do nothing / report nothing if already at floor bool isDooropen O; // returns true of door is open, false otherwise bool isMoving) // rturns true if elevator is moving, false otherwise void reportActionCElevator: :action) const; // reports action to standard output std: :string toString) const; // returns string representation of Elevator private: std::string name; // name of the elevator int numFloors, // total number of floors // current floor currFloor timeBetweenFloors; II time between floor, in milliseconds bool inService, // is elevator in service? doorOpen,I/ is the door open? moving; // is the elevator moving? h: #endif You may not modify file Elevator.h in any way. (Let your instructor know asap if you think it needs to be modified!) Your toString and reportAction routines should produce output exactly like the sample run below. 3 Sample Driver Here is a sample driver program elevatorDriver.cpp that can be used as the first step in testing your clas:s #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
