15-110 FALL 2009 [CORTINA]

LAB 7 - due Friday, Oct 30 by 9PM

A very simple elevator starts at a given floor of a 20-story building with no basement. The maximum capacity of the elevator is 15 people. The elevator starts with no people on board.

In the elevator, there is an UP button and a DOWN button. If the UP button is pushed, the elevator immediately goes up one floor. However, if the UP button is pushed and the elevator is already at the top floor, it stays there. If the DOWN button is pushed, the elevator immediately goes down one floor. However, if the DOWN button is pushed and the elevator is already at the bottom (first) floor, it stays there.

At each floor, we have the option to add passengers to the elevator or remove passengers from the elevator. If we add passengers and there is not enough room for all of the passengers we're adding, then we add only an amount that will bring the elevator to maximum capacity (the others are left to wait). If we remove passengers and the amount we want to remove is more than we have in the elevator, we will remove all remaining passengers on the elevator.

In this lab, you will define the various parts of a class named Elevator to simulate this object.

EXERCISES

Click HERE to download a project named Elevator that you will complete for this lab. Move this to your workspace and open it in Eclipse. There is a ElevatorSimulator class that has a main method that will create an elevator and then present the user with a menu. Each menu option corresponds to an action we can perform on the elevator. You must complete the Elevator class to model an elevator based on the introduction above.

1. Perform the following to start the Elevator class:

2. Add the following mutators to the Elevator class:

3. Add the following additional mutators to the Elevator class:

Additional Exercises (time permitting)

1. Read through the main method to learn how to create a menu system for this elevator simulator.

2. Add one more mutator of your choice to the Elevator and modify the elevator simulator so the user can select your new behavior.

HANDIN

At the end of lab, create a zip file of your program and submit it to the handin server: http://handin.intro.cs.cmu.edu/v1