cscie160.hw1
Class Elevator

java.lang.Object
  |
  +--cscie160.hw1.Elevator

public class Elevator
extends java.lang.Object


Field Summary
static int CAPACITY
           
static int NUM_FLOORS
           
 
Constructor Summary
Elevator()
           
 
Method Summary
 void boardPassenger(int destinationFloor)
          Board a passenger destined for a floor.
 int findDirection()
          Return the direction of closest destination floor, with preference for moving down.
 void go()
          Drive elevator to next destination.
static void main(java.lang.String[] argv)
          Create an elevator and board two passengers into it.
 void move()
          Move elevator one floor in the travelDirection.
 void stop()
          Stop the elevator and unload passengers destined for this floor.
 java.lang.String toString()
          Override the toString() method of java.lang.Object for printing Elevator values.
 void unloadPassenger()
          Unload a passenger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CAPACITY

public static final int CAPACITY
See Also:
Constant Field Values

NUM_FLOORS

public static final int NUM_FLOORS
See Also:
Constant Field Values
Constructor Detail

Elevator

public Elevator()
Method Detail

move

public void move()
Move elevator one floor in the travelDirection.


boardPassenger

public void boardPassenger(int destinationFloor)
Board a passenger destined for a floor.

Parameters:
destinationFloor - The floor that passenger wants to go to.

unloadPassenger

public void unloadPassenger()
Unload a passenger.


stop

public void stop()
Stop the elevator and unload passengers destined for this floor.


findDirection

public int findDirection()
Return the direction of closest destination floor, with preference for moving down.

Returns:
Direction of closest destination floor.

go

public void go()
Drive elevator to next destination.


toString

public java.lang.String toString()
Override the toString() method of java.lang.Object for printing Elevator values.

Overrides:
toString in class java.lang.Object
Returns:
summary of pertinent values in elevartor.

main

public static void main(java.lang.String[] argv)
Create an elevator and board two passengers into it.