m865.simulation
Class Elevator

java.lang.Object
  extended by m865.simulation.Elevator

public class Elevator
extends java.lang.Object

The Elevator class.

  1. If elevator is moving, what its direction is (moving up or down) and which floor elevator is going to.
  2. If elevator is idle, which floor elevator is at.
  3. Passengers inside elevator.
  4. Elevator capacity.
  5. Load and Unload passengers.

  6. Nested Class Summary
    static class Elevator.State
              The three states of an elevator relative to its motion.
     
    Field Summary
    protected  int capacity
              Elevator capacity
    protected  Elevator.State currentDirection
              The state of the elevator's motion
    protected  int currentFloor
              The floor the elevator is at
    protected  int[] passengerFloor
              Array of Floors corresponding to the passengers inside the elevator
    protected  java.util.ArrayList<Passenger> passengers
              ArrayList of Passengers inside the elevator
     
    Constructor Summary
    Elevator(int capacity, int nf)
              Constructor for the Elevator class
     
    Method Summary
     boolean anyPassengers()
              Any passengers for the current floor?
     int getCapacity()
              Get the elevator's capacity
     Elevator.State getCurrentDirection()
              Get current elevator's direction
     int getCurrentFloor()
              Get current elevator's floor
     int getNumberOfPassengers()
              Number of passengers inside the elevator
     void loadPassenger(Passenger p)
              Load Passenger LoadEvent will send the passenger and the corresponding floor to the elevator
     void setDirection(Elevator.State dir)
              update elevator direction MoveOnEvent will send this information to elevator
     void setFloor(int floor)
              update current floor ElevatorArrivalEvent will send this information to elevator
     Passenger unloadPassenger()
              Unload Passenger OffLoadEvent will request a passenger for this floor
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    currentDirection

    protected Elevator.State currentDirection
    The state of the elevator's motion


    currentFloor

    protected int currentFloor
    The floor the elevator is at


    capacity

    protected int capacity
    Elevator capacity


    passengers

    protected java.util.ArrayList<Passenger> passengers
    ArrayList of Passengers inside the elevator


    passengerFloor

    protected int[] passengerFloor
    Array of Floors corresponding to the passengers inside the elevator

    Constructor Detail

    Elevator

    public Elevator(int capacity,
                    int nf)
    Constructor for the Elevator class

    Parameters:
    capacity - The maximum number of passengers the elevator can hold
    nf - The number of floors the elevator can visit.
    Method Detail

    getCapacity

    public int getCapacity()
    Get the elevator's capacity


    setDirection

    public void setDirection(Elevator.State dir)
    update elevator direction MoveOnEvent will send this information to elevator


    getCurrentDirection

    public Elevator.State getCurrentDirection()
    Get current elevator's direction


    setFloor

    public void setFloor(int floor)
    update current floor ElevatorArrivalEvent will send this information to elevator


    getCurrentFloor

    public int getCurrentFloor()
    Get current elevator's floor


    getNumberOfPassengers

    public int getNumberOfPassengers()
    Number of passengers inside the elevator


    loadPassenger

    public void loadPassenger(Passenger p)
    Load Passenger LoadEvent will send the passenger and the corresponding floor to the elevator


    anyPassengers

    public boolean anyPassengers()
    Any passengers for the current floor?


    unloadPassenger

    public Passenger unloadPassenger()
    Unload Passenger OffLoadEvent will request a passenger for this floor