Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help on line 20 of Program.Java, this program is supposed to: City.Java: -This class represents each city that is loaded in from a

I need help on line 20 of Program.Java, this program is supposed to:

City.Java:

-This class represents each city that is loaded in from a text file. It is a simple class that just contains the city's name, x and y coordinates, and a CityMarker icon.

CompressedArray.Java:

- This class represents the array that has been compressed from a matrix (2D array) into a linear array that excludes elements from the diagonal and any elements above or to the right of the diagonal. Only elements below or to the left of the matrix diagonal must be included in the CompressedArray

Program.Java:

-This class, as its name suggests, will be the main heart of the program. It will be the entry point of the program, read in a file of cities and create objects for each of them, contain the array of those cities, and create a CompressedArray containing the distances between each of the cities read in from the file.

Inputs are such as:

USA

20

30

image text in transcribedimage text in transcribed

D'City.java X *Program.java public class City { Compressed Array.java X import java.util.Arrays; public class CompressedArray { private int origArraySize; private double array(); private String name; private int x; private int y; private CityMarker marker; public City(String name, int x, int y) { this.name = name; this.x = x; this.y = y; } 8- 60 7 8 9 10 11 12 13 14 15 16 17 public CompressedArray (double[][] aArray) { int n = aArray.length; int total = (n + (n - 1)) / 2; int i, j, k = 0; origArraySize = total; array = new double[total]; public String getName() { return name; } for (i = 0; ij) array[k++] = Array[i][i]; } 18 public int getX() { return x; } 19 } public int getLength() { return origArraySize; } public int gety () { return y; } public double getElement(int i) { return array[i]; } public CityMarker getMarker() { return marker; } 9 10 11 12 13 140 15 16 17 186 19 20 21 22 230 24 25 26 270 28 29 30 310 32 33 34 350 36 37 38 396 40 41 42 43 440 $45 46 47 47 480 149 50 51 52 } 53 public void setName(String newName) { this.name = newName; } @Override public boolean equals(object obj) { if (this == obj) { return true; public void setx(int newX) { this.x = newX; } 20 210 22 23 24 256 26 27 28 290 A 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 500 A51 52 53 54 if (obj == null) { return false; } if (getClass() != obj.getClass() { return false; } final CompressedArray other = (CompressedArray) obj; if (this.origArraySize != other.origArraySize ) { return false; public void setY(int newy) { this.y = newy; } !)) public void setMarker (CityMarker newMarker) { this.marker = newMarker; } if (!Arrays.equals(this.array, other.array)) { return false; } return true; } @Override public String toString() { return "City Name:" + this.name; } @Override public String toString() 1 String t = ""; for (int i = 0; i <>

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

3. Explain the process of how loans undergo securitization. LOP8

Answered: 1 week ago