Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All done in C++ format thank you Elevator.h File #ifndef ELEVATOR_H #define ELEVATOR_H class Elevator { public: //constructor: Elevator(int initFloor); //post: receives initial floor you

All done in C++ format thank you

Elevator.h File

#ifndef ELEVATOR_H #define ELEVATOR_H class Elevator { public: //constructor: Elevator(int initFloor); //post: receives initial floor you are starting at. // set private var currentFloor // cout something like: "starting on floor " + currentFloor //public method(s) void select(int target); //post: receives the target floor you wish to get to // if current floor > target floor (going up) // create a loop from currentFloor to target floor++ // cout something like "going up to " + number in loop // else if current floor < target floor (going down) // create a loop from currentFloor to target floor-- // cout "something like going down to " + number in loop // cout something like open at + currentFloor //private vars private: int currentFloor; //tracks current floor }; #endif 

File 8F_ ElevatorTestDriver.cpp (

//Student Name //8.3 ElevatorTestDriver.cpp //this program will take the elevator class out for a test drive! #include "Elevator.h" #include  // for cout, cin, system("pause") using namespace std; // so I don't have to say iostream::cout int main() { cout << "Student Name, CIS127, Assignment 2.1" << endl; Elevator elevator(1); elevator.select(5); elevator.select(3); system("pause"); } /* paste output here!!! */ 

Files you will be submitting: Elevator.cpp with output Notes: Remember to add your information to output and copy and paste output to the bottom of the main program Points: 10

General Directions:

I have attached the Elevator.h and 8F_ElevatorTestDriver.cpp file above.

The ElevatorTestDriver creates a new object of Elevator class starting on floor 1(using the constructor). It then takes a trip to the 5th floor and then returns to the 3rd floor. Along the way it prints out all kinds of nice stuff (See results at bottom).

Your job is to take the .h file and create Elevator.cpp from it.

Start out by copying the files above into your project directory. Add 8F_ElevatorTextDriver.cpp to your source files. Open it up and right-click Elevator.h and select open Elevator.h so you can view it.

Create a new source file called Elevator.cpp. - include "Elevator.h" as well as (you need iostream for cout - type in your standard using namespace std; - Copy the constructor and the method "select" from the .h file and paste them into your Elevator.cpp file which you have created. - Convert the method "descriptors" into actual methods by adding the class name before the method name and open/closing curly braces after the method parameters. - Complete the methods using the comments that I have provided as a guide. - When you have completed the two methods, you should be able to run the elevatorTestDriver.cpp and get the results as seen below.

Results:

Student Name, CIS127, Assignment 8.3 Start on floor 1 Going up to floor 2 Going up to floor 3 Going up to floor 4 Going up to floor 5 Open at floor 5 Going down to floor 4 Going down to floor 3 Open at floor 3

Press any key to continue . . .

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. Identify the purpose of your speech

Answered: 1 week ago