Class TransitSystem

java.lang.Object
  |
  +--TransitSystem

public class TransitSystem
extends java.lang.Object

This class builds and manages the transit system for homework 5.


Constructor Summary
TransitSystem()
          Create a set of buses for this transit system.
 
Method Summary
 void addBus(TransitBus bus)
          Add a bus to the busList.
 TransitBus findClosestBus(Locatable obj)
          Find the bus closest to the given Locatable object
 TransitBus findClosestBusOnRoute(int route, Locatable obj)
          Find the bus on a particular route that is closest to the given Locatable object
 void printBusList()
          Print out all the buses in the bus list.
 void printBusOnRouteList(int r)
          Print out all the buses in the bus list that are on a given route.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransitSystem

public TransitSystem()
Create a set of buses for this transit system.

Method Detail

addBus

public void addBus(TransitBus bus)
Add a bus to the busList.

Parameters:
bus - the TransitBus to add to the list.

printBusList

public void printBusList()
Print out all the buses in the bus list.


printBusOnRouteList

public void printBusOnRouteList(int r)
Print out all the buses in the bus list that are on a given route.

Parameters:
r - the route to look for

findClosestBus

public TransitBus findClosestBus(Locatable obj)
Find the bus closest to the given Locatable object

Parameters:
obj - a Locatable object
Returns:
the TransitBus closest to obj. Returns null if the the other location is null, or if there are no buses in the busList.

findClosestBusOnRoute

public TransitBus findClosestBusOnRoute(int route,
                                        Locatable obj)
Find the bus on a particular route that is closest to the given Locatable object

Parameters:
route - the route of interest
obj - a Locatable object
Returns:
the TransitBus closest to obj. Returns null if the the other location is null, or if there are no buses in the busList on this particular route.