Question
Table 1: City Class Class City implements Comparable Private Instance Variables Description String city City name double gpsX GPS Longitude in Decimal Degrees double gpsY
Table 1: City Class
Class City implements Comparable | |
Private Instance Variables | Description |
String city | City name |
double gpsX | GPS Longitude in Decimal Degrees |
double gpsY | GPS Latitude in Decimal Degrees |
int population | Population |
int vertIndex | Index in Vertex ArrayList |
Public Instance Methods | Description |
City (String name, double x, double y, int size, int index) | Constructor to initialize each instance variable. Do not round these numbers, here do the rounding in printCity(). |
String getCity() | Getter for city |
double getLongitude() | Getter for gpsX |
double getLatitude() | Getter for gpsY |
int getPopulation() | Getter for population |
int getIndex() | Getter for vertIndex |
void setIndex (int index) | Setter for vertIndex |
int compareTo (City c) | Compares population |
boolean equals (Object c) | Override equals comparing city name |
String toString() | Return City name |
String printCity() | Return City object information with the GPS coordinates rounded to 2 decimal places, as Mars Hill: [1]:[-82.55, 35.83]:(1869) |
public class City implements Comparable
/** Construct a City object and initialize the instance variables */
public City (String name, double x, double y, int size, int index) { // add code }
/** Return the City name */
public String getCity() { // add code }
/** Return the City longitude */
public double getLongitude() { // add code }
/** Return the City latitude */
public double getLatitude() { // add code }
/** Return the City poulation */
public int getPopulation() { // add code }
/** Return the City index in the vertex ArrayList */
public int getIndex() { // add code }
/** Set the City index of the vertex ArrayList */
public void setIndex (int index) { // add code }
/** Compare the City poulations */
@Override public int compareTo (City c) { // add code }
/** Return true, when the City names are the same */
@Override public boolean equals (Object c) { // add code }
/** * Return the City info as a String * Example: Mars Hill: [1]:[82.55 W, 35.83 N]:(1869) * Round the GPS coordinates to 2 decimal places for display */
public String printCity() { // add code as above }
/** Return the City name as a String */
public String toString() { // add code } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started