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 { private String city; // City name private double gpsX; // Longitide in degrees private double gpsY; // Latitide in degrees private int population; // Population size private int vertIndex; // index in the Vertex ArrayList

/** 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!