Question: Modified from an assignment created by Stuart Reges of the University of Washington (Seattle, WA). Getting Started Follow these steps to get the project loaded

Modified from an assignment created by Stuart Reges of the University of Washington (Seattle, WA).

Getting Started

Follow these steps to get the project loaded in NetBeans.

  1. Download the attached zip file: GeoLocation.zip
  2. Uncompress the file by right-clicking it and choosing Extract All.
  3. Open NetBeans.
  4. Choose File -> Open Project.
  5. Browse to the Geo Location folder you uncompressed and open it.
  6. Click the Open Project button.

You should now see the project loaded into NetBeans. Let me know if you have trouble.

Part 1

In this part of the lab you will write client code to manipulate some GeoLocation objects. The GeoLocation class is being provided to you, so you don't have to write it. You will instead be writing code that constructs and manipulates three GeoLocation objects.

The popular TV series Breaking Bad made use of geographic location information. The Walter White character buried millions of dollars at a particular location in the desert outside of Albuquerque, New Mexico. He then bought a lottery ticket to help him remember that his stash was buried at a latitude of 34 degrees, 59 minutes, 20 seconds and a longitude of -106 degrees, 36 minutes, 52 seconds. Your client program will compute the distance between Walter's stash and the local FBI building and a local studio known as ABQ Studios (where Breaking Bad was filmed).

Your program should produce the following output:

The stash is at latitude: 34.988889, longitude: -106.614444 ABQ studio is at latitude: 34.989978, longitude: -106.614357 FBI building is at latitude: 35.131281, longitude: -106.61263 Distance in miles between: stash/studio = 0.07548768123801672 stash/fbi = 9.849836190409732

Instructions:

  1. Create a new Java class in NetBeans called GeoLocationClient. This class is a main class and should have a main method.
  2. Create three GeoLocation objects with the values you see in the output above.
  3. Print the three objects and call the distanceFrom method twice to get the desired output. Please note that the latitude/longitude information in the first three lines of output should be produced by calls to the GeoLocation's toString method, and the values in the final two lines of output should be produced by calls to the GeoLocation's distanceFrom method.

Part 2 - Optional, for more practice writing an instantiable class

For this part of the lab, you will write a class called PlaceInformation that stores information about a place of interest. It should have the following instance variables:

private String name; private String address; private String tag; private GeoLocation location;

It should have the following public methods:

public PlaceInformation(String inName, String inAddress, String inTag, double inLatitude, double inLongitude) public String getName() public String getAddress() public String getTag() public String toString() public GeoLocation getLocation() public double distanceFrom(GeoLocation spot)

The first three "get" methods simply return the values that were provided when the object was constructed. The toString method should return the name followed by the location details. Although the constructor takes a latitude and longitude, you should store this information inside the PlaceInformation object using a GeoLocation object. The getLocation method should return a reference to this GeoLocation object. Remember that in writing your class, you don't want to include code that appears elsewhere. For example, your GeoLocation object knows how to compute a distance, so you should not be repeating the code for computing distances in your PlaceInformation class. You should instead be asking the GeoLocation object to perform the computation. This class is similar to the GeoLocation class, so you can use it as a model for how to write your own class. We are providing a client program called PlaceInformationClient.java that can be used to test your class.

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!