|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectAmericanCity
public class AmericanCity
The AmericanCity class represents a simple city, where the name of the
given city, and the state code are stored in private String instance
variables. This class is to be used for HW4 . For a complete description,
of this assignment go to:
http://www.cs.sunysb.edu/~cse114/hw/HW4.html
This class only performs very basic functions, allowing the altering and
retrieving of String variables that represent a city name and state code.
In addition, a simple toString method is provided to get a String representation
of this object in a neat form.
Author:
Richard T. McKenna
Instructor
CSE 114 - Computer Science I - Fall 2009
Stony Brook University
Constructor Summary | |
---|---|
AmericanCity()
Default Constructor for AmericanCity, when called it initializes both the city name and the state code to NOWHERE. Preconditions: The AmericanCity() constructor is called by a program and the result is assigned either to a variable of type AmericanCity or is passed to another method as a parameter of type AmericanCity. Postconditions: An AmericanCity object is constructed and memory is reserved for use for that object. |
|
AmericanCity(java.lang.String initCity,
java.lang.String initStateCode)
Second Constructor for AmericanCity, when called it initializes both the city and the stateCode to values provided in the parameter list. Preconditions: This constructor is called by a program and the result is assigned either to a variable of type AmericanCity or is passed to another method as a parameter of type AmericanCity. Postconditions: An AmericanCity object is constructed and memory is reserved for use for that object. |
Method Summary | |
---|---|
java.lang.String |
getCity()
Accessor method that returns the city String. Preconditions: this AmericanCity object must be constructed with instance variables properly initialized. Postconditions: The city instance variable is returned. |
java.lang.String |
getStateCode()
Accessor method that returns the state code String. Preconditions: this AmericanCity object must be constructed with instance variables properly initialized. Postconditions: The stateCode instance variable is returned. |
static boolean |
isValidStateCode(java.lang.String testStateCode)
A static method that tests to see whether the testStateCode provided in the paramter list is a valid state code. |
void |
setCity(java.lang.String changeCity)
Mutator method that allows the programmer to change the city. Preconditions: this AmericanCity object must be constructed. Postconditions: The city instance variable is assigned the value of changeCity. |
void |
setStateCode(java.lang.String changeStateCode)
Mutator method that allows the programmer to change the state code. Preconditions: this AmericanCity object must be constructed. Postconditions: The stateCode instance variable is assigned the value of changeState, using Upper Case letters. |
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 |
---|
public AmericanCity()
public AmericanCity(java.lang.String initCity, java.lang.String initStateCode)
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.Method Detail |
---|
public java.lang.String getCity()
public java.lang.String getStateCode()
public void setCity(java.lang.String changeCity)
changeCity
- The String value to be used to set the
city for the specified AmericanCity.public void setStateCode(java.lang.String changeStateCode)
changeStateCode
- The String value to be used to set the
state code for the specified AmericanCity.public java.lang.String toString()
toString
in class java.lang.Object
public static boolean isValidStateCode(java.lang.String testStateCode)
testStateCode
- A String value to be tested to see if it
represents a valid state code.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |