stresstests.datasets
Class City

java.lang.Object
  extended by stresstests.datasets.City
All Implemented Interfaces:
ISame<City>

public class City
extends java.lang.Object
implements ISame<City>

A simple class to use for learning about classes and objects.


Field Summary
 double latitude
          The latitude for this city
 double longitude
          The longitude for this city
 java.lang.String name
          The name of this city.
 java.lang.String state
          The state for this city
 int zip
          The zip code for this city.
private static java.text.DecimalFormat zipFormat
          Decimal format to print leading zeros in zip code
 
Constructor Summary
City()
          The default constructor
City(City aCity)
          The copy constructor
City(int zip, java.lang.String name, java.lang.String state, double longitude, double latitude)
          The full constructor
City(java.lang.String zip, java.lang.String name, java.lang.String state, double longitude, double latitude)
          The full constructor that uses String for zip code input
 
Method Summary
 int decimal(java.lang.String s)
          a helper method to convert zip code String to int
protected  double doubleValue(java.lang.String s)
          convert a String to double - if possible
 void fromStringData(java.lang.String s)
          Convert the String that represents a City to city data
protected  int intValue(java.lang.String s)
          convert a String to int - if possible
static void main(java.lang.String[] argv)
          Self Tests
 boolean same(City city)
          determine whether this City is the same as the given City
protected  boolean sameDouble(double d1, double d2, double limit)
          helper method to compare doubles
 java.lang.String toString()
          print the City data
 java.lang.String toStringData()
          Convert City data to well structured string for file output
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

zip

public int zip
The zip code for this city.


name

public java.lang.String name
The name of this city.


state

public java.lang.String state
The state for this city


longitude

public double longitude
The longitude for this city


latitude

public double latitude
The latitude for this city


zipFormat

private static java.text.DecimalFormat zipFormat
Decimal format to print leading zeros in zip code

Constructor Detail

City

public City(int zip,
            java.lang.String name,
            java.lang.String state,
            double longitude,
            double latitude)
The full constructor


City

public City(City aCity)
The copy constructor


City

public City(java.lang.String zip,
            java.lang.String name,
            java.lang.String state,
            double longitude,
            double latitude)
The full constructor that uses String for zip code input


City

public City()
The default constructor

Method Detail

toStringData

public java.lang.String toStringData()
Convert City data to well structured string for file output


same

public boolean same(City city)
determine whether this City is the same as the given City

Specified by:
same in interface ISame<City>
Parameters:
city - object
Returns:
true is the two objects are the same (by our definition)

sameDouble

protected boolean sameDouble(double d1,
                             double d2,
                             double limit)
helper method to compare doubles


fromStringData

public void fromStringData(java.lang.String s)
                    throws java.text.ParseException
Convert the String that represents a City to city data

Throws:
java.text.ParseException

intValue

protected int intValue(java.lang.String s)
                throws java.text.ParseException
convert a String to int - if possible

Throws:
java.text.ParseException

doubleValue

protected double doubleValue(java.lang.String s)
                      throws java.text.ParseException
convert a String to double - if possible

Throws:
java.text.ParseException

toString

public java.lang.String toString()
print the City data

Overrides:
toString in class java.lang.Object

decimal

public int decimal(java.lang.String s)
a helper method to convert zip code String to int


main

public static void main(java.lang.String[] argv)
Self Tests