|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cscie160.hw3.Floor
CSCIE160
Assignment 2: Elevator part 2
Floor class: This class complements the elevator class for the elevator project.
By David Cheung
Field Summary | |
java.util.LinkedList |
llDown
llDown |
java.util.LinkedList |
llResidential
llResidential |
java.util.LinkedList |
llUp
staUp |
Constructor Summary | |
Floor(int i)
Floor constructor: |
Method Summary | |
void |
addOnePassenger(Elevator myElevator,
Passenger aPass)
addOnePassenger |
int |
getFloorIdentifier()
getFloorIdentifier |
void |
loadPassengers(Elevator myElevator,
int numOfPeople)
loadPassengers |
void |
loadPassengers(java.util.LinkedList llGetList)
loadPassenger |
void |
PrintPassengers()
PrintPassengers |
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 |
public java.util.LinkedList llResidential
This list stores passengers when they arrive at the destinated floor.
public java.util.LinkedList llUp
this stack stores the passengers that are in the up queue.
public java.util.LinkedList llDown
this list stores the passengers that are in the down queue.
Constructor Detail |
public Floor(int i)
sets floorIdentifier.
i
- The floor number of the floor.Method Detail |
public void unloadPassengers(Elevator anElevator)
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)
March 14, 2001: For HW3, when unloading passengers, a collection of passengers is passed to the floor. This is done to replace the old integer representation of the passengers.
public void addOnePassenger(Elevator myElevator, Passenger aPass)
This method addes one passenger to the queue. Tries to determine if the passenger needs to go down or go up. Then appropiately add the passenger to the correct list.
public void loadPassengers(Elevator myElevator, int numOfPeople)
This method is not called by the elevator, but used as test method to load in passengers. Load one passenger at a time.
for HW3: added random generator for destination floors. Assumes that the max floor is seven, which is not seen by Floor.
Elevator
- the handle to the elevatornumOfPeople
- state how many people to generate.public void loadPassengers(java.util.LinkedList llGetList)
This method is called by the elevator. This passes the whole linklist of passengers from elevator's llPassDestForEachFloor and add it to the current floors' residential list.
public java.lang.String toString()
For debugging use. Returns the numOfPassengers for this floor
toString
in class java.lang.Object
public void PrintPassengers()
prints stats for the passengers
public int getFloorIdentifier()
returns the FloorIdentifier of the floor
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |