cscie160.hw2
Class Floor

java.lang.Object
  |
  +--cscie160.hw2.Floor

public class Floor
extends java.lang.Object

CSCIE160

Assignment 2: Elevator part 2

Floor class: This class complements the elevator class for the elevator project.

By David Cheung


Field Summary
 int floorIdentifier
          This is the floor number of the floor.
 
Constructor Summary
Floor(int i)
          Floor constructor:
 
Method Summary
 void loadPassengers(Elevator myElevator, int numOfPeople)
          loadPassengers This is not called by the elevator, but used as test method to load in passengers.
 java.lang.String toString()
          toString
 void unloadPassengers(Elevator anElevator)
          unloadPassengers:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

floorIdentifier

public int floorIdentifier
This is the floor number of the floor.

This is used for debugging purposes only.

Constructor Detail

Floor

public Floor(int i)
Floor constructor:

sets floorIdentifier.

Parameters:
i - The floor number of the floor.
Method Detail

unloadPassengers

public void unloadPassengers(Elevator anElevator)
unloadPassengers:

This Method consists of 2 parts:

The first part is from hw1's stop(). The second part is the new implemented exception feature.

After unloading people in the elevator, this function attempts to board passengers to the elevator if sucessful, then method completes. If elevator happens to be full, then this method will cause Elevator's boardPassenger function to throw an exception. Thus the remaining passengers will be left on the floor.

If the exception was thrown, then a registerRequest to the elevator will be initiated. (Done in Catch)


loadPassengers

public void loadPassengers(Elevator myElevator,
                           int numOfPeople)
loadPassengers This is not called by the elevator, but used as test method to load in passengers.

toString

public java.lang.String toString()
toString

For debugging use. Returns the numOfPassengers for this floor

Overrides:
toString in class java.lang.Object