Class TripCity

java.lang.Object
  extended by AmericanCity
      extended by TripCity

public class TripCity
extends AmericanCity

The Trip class is both an executable class and an instantiatable class that each student must further define for HW4. For a complete description, of this assignment go to:

http://www.cs.stonybrook.edu/~cse114/hw/HW4.html


This class runs a program that provides a menu to the user such that they may enter trip information, including the starting city and destination city, as well as the Latitude/Longitude coordinates of those respective cities. This program then prints a trip summary including the trip cities and the trip distance, which should be calculated by a method in this class.

Author: Ian Sutherland
 
  CSE 114 - Computer Science I - Fall 2009
  Stony Brook University


Constructor Summary
TripCity()
          Default Constructor for TripCity, when called it initializes both the city name and the state code to NOWHERE and coordinates to 0.
TripCity(java.lang.String initCity, java.lang.String initStateCode, int lat_deg, int lat_min, char lat_dir, int long_deg, int long_min, char long_dir)
          Default Constructor for TripCity, when called it initializes both the city name, the state code, and coordinates to the provided parameters
 
Method Summary
 double calcDistance(TripCity otherCity)
          Method that returns a Double that represents the distance in miles between two TripCity objects.
 void setCity(java.lang.String initCity, java.lang.String initStateCode, int lat_deg, int lat_min, char lat_dir, int long_deg, int long_min, char long_dir)
          Mutator method for TripCity, when called it sets both the city name, the state code, and coordinates to provided paramaters
 java.lang.String toString()
          Method that returns a string that "textually represents" this object.
 
Methods inherited from class AmericanCity
getCity, getStateCode, isValidStateCode, setCity, setStateCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TripCity

public TripCity()
Default Constructor for TripCity, when called it initializes both the city name and the state code to NOWHERE and coordinates to 0.


TripCity

public TripCity(java.lang.String initCity,
                java.lang.String initStateCode,
                int lat_deg,
                int lat_min,
                char lat_dir,
                int long_deg,
                int long_min,
                char long_dir)
Default Constructor for TripCity, when called it initializes both the city name, the state code, and coordinates to the provided parameters

Parameters:
initCity - The String value used to initialize the city of the specified AmericanCity.
initStateCode - The String value used to initialize the state code of the specified AmericanCity.
lat_deg - the int value used for the latitude degrees
lat_min - the int value used for the latitude minutes
lat_dir - the char value used for the latitude direction (n/s)
long_deg - the int value used for the longitude degrees
long_min - the int value used for the longitude minutes
long_dir - the char value used for the longitude direction (e/w)
Method Detail

setCity

public void setCity(java.lang.String initCity,
                    java.lang.String initStateCode,
                    int lat_deg,
                    int lat_min,
                    char lat_dir,
                    int long_deg,
                    int long_min,
                    char long_dir)
Mutator method for TripCity, when called it sets both the city name, the state code, and coordinates to provided paramaters

Parameters:
initCity - The String value used to initialize the city of the specified AmericanCity.
initStateCode - The String value used to initialize the state code of the specified AmericanCity.
lat_deg - the int value used for the latitude degrees
lat_min - the int value used for the latitude minutes
lat_dir - the char value used for the latitude direction (n/s)
long_deg - the int value used for the longitude degrees
long_min - the int value used for the longitude minutes
long_dir - the char value used for the longitude direction (e/w)

toString

public java.lang.String toString()
Method that returns a string that "textually represents" this object.

Overrides:
toString in class AmericanCity
Returns:
a textual representation of the specified TripCity

calcDistance

public double calcDistance(TripCity otherCity)
Method that returns a Double that represents the distance in miles between two TripCity objects.

Returns:
a Double value representing the distance between two TripCity objects