m865.simulation
Class Passenger

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

public class Passenger
extends java.lang.Object

A class representing passengers in the elevator simulation for Dr. Warner's MTHSC 865 class at Clemson University.


Nested Class Summary
static class Passenger.FloorTimePair
          A simple class representing a floor and time pair, telling us what floor we need to be at and how much time we'll spend there.
static class Passenger.State
          The possible states the passenger may be in.
 
Constructor Summary
Passenger(java.util.List<Passenger.FloorTimePair> schedule, DepartmentStore deptStore)
          Create a new passenger with the given schedule, a list of FloorTimePair objects.
Passenger(java.util.List<Passenger.FloorTimePair> schedule, DepartmentStore deptStore, int maxWaitingTime, int walkingTime, int loadingTime, int unloadingTime)
          Create a new passenger with the given schedule, a list of FloorTimePair objects.
 
Method Summary
 void balk()
          Stop waiting for the elevator and take the stairs.
 BalkEvent getBalkEvent()
          Get the BalkEvent associated with this passenger.
 int getCurrentFloor()
          Get the floor the passenger is currently on.
 Passenger.FloorTimePair getCurrentFloorTimePair()
          Get the FloorTimePair of the passenger's current task.
 int getLoadingTime()
          Get the amount of time it takes the passenger to get onto the elevator.
 int getMaxWait()
          Get the maximum amount of time the passenger is willing to wait on the elevator before taking the stairs.
 int getNextFloor()
          See which floor the passenger's next task is on.
 Passenger.FloorTimePair getNextFloorTimePair()
          Get the next FloorTimePair, telling us where the passenger needs to go next.
 int getNumBalks()
          Get the number of times the passenger has balked.
 java.util.List<Passenger.FloorTimePair> getSchedule()
          Retrieve the passenger's schedule.
 Passenger.State getState()
          The passenger's current state.
 java.lang.Integer[] getTravelTimes()
          Get an array of the times the passenger spent travelling on the elevator.
 int getUnloadingTime()
          Get the amount of time it takes the passenger to get off of the elevator.
 java.lang.Integer[] getWaitingTimes()
          Get an array of the times the passenger spent waiting on the elevator.
 int getWalkingTime()
          Get the amount of time it takes the passenger to walk up or down a flight of stairs.
 boolean hasMoreToDo()
          See if the passenger has more tasks they need to complete.
 void removeBalkEvent()
          Remove the BalkEvent associated with this passenger.
 void setBalkEvent(BalkEvent e)
          Tell the passenger which BalkEvent they're associated with.
 java.lang.String toString()
          Get a String representation of the passenger.
 void updateTime()
          Update the passenger's time records.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Passenger

public Passenger(java.util.List<Passenger.FloorTimePair> schedule,
                 DepartmentStore deptStore)
Create a new passenger with the given schedule, a list of FloorTimePair objects. Note: This constructor is included for compatability purposes only, so the Passenger class will compile with older code. Use the other constructor in your own code.

Parameters:
schedule - The passenger's schedule.
deptStore - The department store the passenger is visiting.

Passenger

public Passenger(java.util.List<Passenger.FloorTimePair> schedule,
                 DepartmentStore deptStore,
                 int maxWaitingTime,
                 int walkingTime,
                 int loadingTime,
                 int unloadingTime)
Create a new passenger with the given schedule, a list of FloorTimePair objects.

Parameters:
schedule - The passenger's schedule.
deptStore - The department store the passenger is visiting.
maxWaitingTime - The maximum amount of time the passenger will wait on the elevator before taking the stairs.
walkingTime - The amount of time it takes the passenger to walk up and down one flight of stairs.
loadingTime - The time it takes the passenger to get onto the elevator.
unloadingTime - The time it takes the passenger to get off of the elevator.
Method Detail

getState

public Passenger.State getState()
The passenger's current state.

Returns:
The passenger's current state.

getWalkingTime

public int getWalkingTime()
Get the amount of time it takes the passenger to walk up or down a flight of stairs.

Returns:
The amount of time it takes the passenger to walk up or down a flight of stairs.

getMaxWait

public int getMaxWait()
Get the maximum amount of time the passenger is willing to wait on the elevator before taking the stairs.

Returns:
The amount of time the passenger will wait before balking.

getLoadingTime

public int getLoadingTime()
Get the amount of time it takes the passenger to get onto the elevator.

Returns:
The amount of time it takes the passenger to get onto the elevator.

getUnloadingTime

public int getUnloadingTime()
Get the amount of time it takes the passenger to get off of the elevator.

Returns:
The amount of time it takes the passenger to get off of the elevator.

updateTime

public void updateTime()
Update the passenger's time records. Records the current time and updates the state of the passenger so the passenger is aware of whether he just arrived at a floor, finished shopping, etc.


setBalkEvent

public void setBalkEvent(BalkEvent e)
Tell the passenger which BalkEvent they're associated with.


getBalkEvent

public BalkEvent getBalkEvent()
Get the BalkEvent associated with this passenger.

Returns:
The BalkEvent associated with the passenger.

removeBalkEvent

public void removeBalkEvent()
Remove the BalkEvent associated with this passenger.


balk

public void balk()
Stop waiting for the elevator and take the stairs.


getNumBalks

public int getNumBalks()
Get the number of times the passenger has balked.

Returns:
The number of times the passenger has balked.

getSchedule

public java.util.List<Passenger.FloorTimePair> getSchedule()
Retrieve the passenger's schedule.

Returns:
The passenger's schedule as a list of FloorTimePair objects.

hasMoreToDo

public boolean hasMoreToDo()
See if the passenger has more tasks they need to complete.


getNextFloorTimePair

public Passenger.FloorTimePair getNextFloorTimePair()
Get the next FloorTimePair, telling us where the passenger needs to go next.

Returns:
The floor and time for the passenger's next task.

getNextFloor

public int getNextFloor()
See which floor the passenger's next task is on.

Returns:
The floor of the passenger's next task.

getWaitingTimes

public java.lang.Integer[] getWaitingTimes()
Get an array of the times the passenger spent waiting on the elevator.

Returns:
The times the passenger spent waiting.

getTravelTimes

public java.lang.Integer[] getTravelTimes()
Get an array of the times the passenger spent travelling on the elevator.

Returns:
The times the passenger spent travelling.

getCurrentFloorTimePair

public Passenger.FloorTimePair getCurrentFloorTimePair()
Get the FloorTimePair of the passenger's current task.

Returns:
The FloorTimePair of the passenger's current task. If the passenger has just arrived and hasn't started shopping yet, null will be returned.

getCurrentFloor

public int getCurrentFloor()
Get the floor the passenger is currently on.

Returns:
The floor the passenger is currently on.

toString

public java.lang.String toString()
Get a String representation of the passenger.

Overrides:
toString in class java.lang.Object
Returns:
A string describing the passenger.