Class Trip

java.lang.Object
  extended by Trip

public class Trip
extends java.lang.Object

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
Trip()
          Default Constructor for Trip, students should add code to this method to initialize all instance variables.
 
Method Summary
 void inputLocation(int locale)
          Method that prompts the user for trip data and then gets that input.
static void main(java.lang.String[] args)
          Driver method for executing the Trip program.
 void runTripProgram()
          Method that displays and controls the program menu.
 java.lang.String toString()
          Method that returns a string that "textually represents" this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Trip

public Trip()
Default Constructor for Trip, students should add code to this method to initialize all instance variables. NOWHERE.

Preconditions: The Trip() constructor is called by a program and the result is assigned either to a variable of type Trip or is passed to another method as a parameter of type Trip.

Postconditions: A Trip object is constructed and memory is reserved for use for that object. The constructed object's instance variables should also be initialized.

Method Detail

runTripProgram

public void runTripProgram()
Method that displays and controls the program menu.
Preconditions: this Trip object must be constructed.

Postconditions: A menu is printed to the screen for the user to use. This method will then get input from the user and execute the necessary method or exit the program depending on the input. Students should not change this method.


inputLocation

public void inputLocation(int locale)
Method that prompts the user for trip data and then gets that input.
Preconditions: this Trip object must be constructed. Also, the locale parameter provided to the method should be equal to either START OR END.

Postconditions: if locale equals START, then the user is prompted to enter data concerning the Trip starting location. This data is then used to initialize the necessary objects in this class. If locale equals END, then the same is done, but for the destination location.

Parameters:
locale - Either START or END, it refers to whether the user is entering data for the trip starting or ending city.

toString

public java.lang.String toString()
Method that returns a string that "textually represents" this object.
Preconditions: this Trip object must be constructed.

Postconditions: A String is returned that summarizes this Trip. Students must add code to this method.

Overrides:
toString in class java.lang.Object
Returns:
a textual representation of the specified Trip

main

public static void main(java.lang.String[] args)
Driver method for executing the Trip program.
Preconditions: all necessary classes are compiled.

Postconditions: A Trip object is constructed, then the runTripProgram() method is run for that program.