/** * A City in California, and its population * * @author P. Conrad (outline, and buggy version) * @author YOUR NAME HERE (student that fixed the bugs as part of lab03) * @version for lab03, CS10, Fall 2009 * @see CACityTest */ public class CACity { private String name; private int population; // as of 2000 census /** * Constructor for objects of class CACity */ public CACity(String name, int population) { // @@@ this code may have some bugs... // @@@ Your tests should catch these! name = this.name; population = population; } /** * getter for name * @return the name of the city */ public String getName() { return this.name; } /** * getter for population * @return the population of the city */ public int getPopulation() { return this.population; } // no setters---this will be an immutable class (see Chapter 8) /** * convert city to a formatted string * like "Santa Barbara (pop. 92325)" * "Goleta (pop. 55204)" * "Isla Vista (pop. 13465)" * @return city formatted as a string, with population in parens */ public String toString() { return name + " (pop. " + population + ")"; } }