Question: Objects and Classes Complete the following exercises by the due date. Make sure your source code using appropriate programming style ( e . g .

Objects and Classes
Complete the following exercises by the due date. Make sure your source code using appropriate
programming style (e.g., descriptive variable names, indenting, comments, etc.).
Exercises
You have been asked to develop a program to simulate the operation of an elevator for a three story
building. Unfortunately, this elevator can only go up or down one floor at a time. So if you want it to go
from the first floor to the third floor, you must tell it to goUp()(from the first to the second floor), and
goUp() again to make it to the third floor. The same applies to goDown().
1. Your Elevator class should have one integer variable: currentFloor.
2. Your class should only need three methods: goUp(), goDown(), and displayCurrentFloor().
3. Write an elevator test program. Have the program execute the following steps using the methods in
the class:
Start on the first floor.
Go to the second floor.
Go to the third floor
Attempt to go to the fourth floor (Remember: there are only three floors)
Go back to the second floor
Go back to the first floor
Be sure to call displayCurrentFloor() to notify the user which floor the elevator is on at each step
Note: you will need separate source file for the class definition and the elevator test program.
What to Turn In
For each exercise, submit the source code and the screen output.
Learning Objectives
This exercise contributes to the development of problem solving and debugging skills. After completing
this exercise, students should understand the properties of creating their own data types and
performing simple operations with them.

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 Programming Questions!