first commit
This commit is contained in:
140
CS1322/p1/City.java
Normal file
140
CS1322/p1/City.java
Normal file
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* <PRE>
|
||||
* City.java
|
||||
* Class City;
|
||||
* A class designed to build cities
|
||||
*
|
||||
* Revisions: 1.0 Sep. 02, 2002
|
||||
* Created the City class
|
||||
* 1.1 Sep. 02, 2002
|
||||
* Finished, compiled, tested
|
||||
*
|
||||
* </PRE>
|
||||
*
|
||||
* Collaboration Statement:
|
||||
* I worked on the homework assignment alone, using only
|
||||
* course materials.
|
||||
*
|
||||
* Created with JCreatorLE, some indents are off when viewed through notepad
|
||||
* or EMACS
|
||||
*
|
||||
* @author <A HREF="mailto:gtg184g@mail.gatech.edu">Jose Manuel Caban</A>
|
||||
* @version Version 1.1, Sep. 02, 2002
|
||||
*/
|
||||
|
||||
public class City {
|
||||
//global/field scope variables
|
||||
private String name;
|
||||
private String country;
|
||||
private long population;
|
||||
public static final boolean bDebug = false; //not much to debug here, tho
|
||||
|
||||
////////////////
|
||||
//Constructors//
|
||||
////////////////
|
||||
|
||||
/**
|
||||
*Constructor for City
|
||||
*@param Sets the name for the City
|
||||
*/
|
||||
public void City(String n){
|
||||
name = n;
|
||||
}
|
||||
|
||||
/**
|
||||
*Default Constructor for City
|
||||
*@param sets the name to "Unknown"
|
||||
*/
|
||||
public void City(){
|
||||
name = "Unknown";
|
||||
}
|
||||
|
||||
/*********************************/
|
||||
|
||||
///////////////////////
|
||||
//Accessors/Modifiers//
|
||||
///////////////////////
|
||||
|
||||
/**
|
||||
*Returns the City name
|
||||
*@return value of name
|
||||
*/
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*Set the City name
|
||||
*@param n value to assign to name
|
||||
*/
|
||||
public void setName(String n){
|
||||
name = n;
|
||||
}
|
||||
|
||||
/**
|
||||
*Return the country name
|
||||
*@return value of country
|
||||
*/
|
||||
public String getCountry(){
|
||||
return country;
|
||||
}
|
||||
|
||||
/**
|
||||
*Set the Country name
|
||||
*@param c value to assign to country
|
||||
*/
|
||||
public void setCountry(String c){
|
||||
country = c;
|
||||
}
|
||||
|
||||
/**
|
||||
*Return the population
|
||||
*@return value of population
|
||||
*/
|
||||
public long getPopulation(){
|
||||
return population;
|
||||
}
|
||||
|
||||
/**
|
||||
*Set the population
|
||||
*@param p the value to assign to population
|
||||
*/
|
||||
public void setPopulation(long p){
|
||||
population = p;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/**
|
||||
* Change standard string to output to be used for this specific program
|
||||
*
|
||||
* <br><br>
|
||||
* @return phrase as string
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return name + ", " + country + ": Population: " + population;
|
||||
}
|
||||
|
||||
/**
|
||||
* Debugging main for class City.
|
||||
* This method will rigorously test my code.
|
||||
*
|
||||
* <br><br>
|
||||
* @param args a String array of command line arguments.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
//run debug with my home town, YAY!!!!
|
||||
City Weston = new City();
|
||||
|
||||
Weston.setName("Weston");
|
||||
Weston.setCountry("United States");
|
||||
Weston.setPopulation(2453); //I think I overshot with that number
|
||||
|
||||
System.out.println(Weston);
|
||||
|
||||
|
||||
}// end of main(String[] args)
|
||||
|
||||
}// end of class City
|
||||
Reference in New Issue
Block a user