|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstresstests.datasets.City
public class 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 |
---|
public int zip
public java.lang.String name
public java.lang.String state
public double longitude
public double latitude
private static java.text.DecimalFormat zipFormat
Constructor Detail |
---|
public City(int zip, java.lang.String name, java.lang.String state, double longitude, double latitude)
public City(City aCity)
public City(java.lang.String zip, java.lang.String name, java.lang.String state, double longitude, double latitude)
String
for zip code input
public City()
Method Detail |
---|
public java.lang.String toStringData()
City
data to well structured string
for file output
public boolean same(City city)
City
is the same as the given
City
same
in interface ISame<City>
city
- object
protected boolean sameDouble(double d1, double d2, double limit)
public void fromStringData(java.lang.String s) throws java.text.ParseException
String
that represents a City
to city data
java.text.ParseException
protected int intValue(java.lang.String s) throws java.text.ParseException
String
to int
- if possible
java.text.ParseException
protected double doubleValue(java.lang.String s) throws java.text.ParseException
String
to double
- if possible
java.text.ParseException
public java.lang.String toString()
City
data
toString
in class java.lang.Object
public int decimal(java.lang.String s)
String
to int
public static void main(java.lang.String[] argv)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |