airline
Class Route

java.lang.Object
  extended by airline.Route

public class Route
extends java.lang.Object


Constructor Summary
Route()
          Creates a new instance of Route.
Route(java.lang.String rt, Airport start, Airport end, java.lang.String catg, int mile)
          Creates a new instance of Route - main info passed
 
Method Summary
 void displayRoute(java.io.PrintWriter outpw)
          display to file info about a route.
 Airport getArrivLoc()
          reports airport (object) for arriving aiport
 Airport getDepartLoc()
          reports airport (object) for departing aiport
 java.lang.String getLengthCatg()
          reports length category for route.
 int getMiles()
          reports distance in miles for the route
 java.lang.String getRouteID()
          report route ID
 boolean isUnknownRoute()
          indicates if the route is an unknown route - probably either not initialized yet, or a problem exists Checks route ID to see if it is "UNK" or miles is negative
 void readRoute(java.io.BufferedReader bReader, CollectAirports allAirports)
          read route info from a file, sticking in the invoking Route object.
 int readRouteFromFile(java.io.BufferedReader bReader, CollectAirports allAirports)
          read an route from a file.
 boolean setArrivLoc(Airport arriv)
          change arriving airport.
 boolean setDepartLoc(Airport depart)
          change departing airport.
 boolean setLengthCatg(java.lang.String catg)
          change length category.
 boolean setMiles(int mil)
          change distance in miles for the route.
 boolean setRouteID(java.lang.String id)
          change route id.
 java.lang.String toString()
          create string represntation for the route.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Route

public Route()
Creates a new instance of Route. Default version has no info. Route is essentially unknown.


Route

public Route(java.lang.String rt,
             Airport start,
             Airport end,
             java.lang.String catg,
             int mile)
Creates a new instance of Route - main info passed

Method Detail

getRouteID

public java.lang.String getRouteID()
report route ID


isUnknownRoute

public boolean isUnknownRoute()
indicates if the route is an unknown route - probably either not initialized yet, or a problem exists Checks route ID to see if it is "UNK" or miles is negative


getDepartLoc

public Airport getDepartLoc()
reports airport (object) for departing aiport


getArrivLoc

public Airport getArrivLoc()
reports airport (object) for arriving aiport


getLengthCatg

public java.lang.String getLengthCatg()
reports length category for route. Should be enumerated type later.


getMiles

public int getMiles()
reports distance in miles for the route


setRouteID

public boolean setRouteID(java.lang.String id)
change route id. Probably should use ID class instead of string


setDepartLoc

public boolean setDepartLoc(Airport depart)
change departing airport. potentially able to be validated if we have a list of known airports.


setArrivLoc

public boolean setArrivLoc(Airport arriv)
change arriving airport. potentially able to be validated if we have a list of known airports.


setLengthCatg

public boolean setLengthCatg(java.lang.String catg)
change length category. Should be enumerated type later


setMiles

public boolean setMiles(int mil)
change distance in miles for the route. Returns false if miles not greater than 30. Does anybody fly from JFK to La Guardia? I hope not.


toString

public java.lang.String toString()
create string represntation for the route. Short versions of airports used to make more compact.

Overrides:
toString in class java.lang.Object

displayRoute

public void displayRoute(java.io.PrintWriter outpw)
display to file info about a route. Depends on having a PrintWriter which can be obtained using my HandleFile class


readRouteFromFile

public int readRouteFromFile(java.io.BufferedReader bReader,
                             CollectAirports allAirports)
                      throws java.io.IOException
read an route from a file. Needs a collection of airports so only have to get code, not everything about the airport.

Throws:
java.io.IOException

readRoute

public void readRoute(java.io.BufferedReader bReader,
                      CollectAirports allAirports)
               throws java.io.IOException
read route info from a file, sticking in the invoking Route object. If exception is thrown, just give up. The file probably needs to be fixed.

Throws:
java.io.IOException