Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

=+ (b) Show that no record stands forever.

Answered: 1 week ago