Question: 1 . In your program define a class called GeoPoint that will have the following: a . An init (self) method that will create two
1. In your program define a class called GeoPoint that will have the following:
a. An init (self) method that will create two attributes (variables) called self.lat, self.lon for the location of that point. The init method will also initialize a description attribute (variable) that will start off as the empty string .
b. A SetPoint(self, lat, lon) method that will set the values of self.lat, self.lon
c. A GetPoint(self) method that will return a data structure with self.lat, self.lon.
d. A Distance(self, lat, lon) method that will figure out the distance between the objects self.lat, self.lon and lat, lon user parameters passed in.
e. A SetDescription(self, description) method that will set the objects self.description attribute (variable).
f. A GetDescription(self) method that will return the objects self.description attribute.
2. In the main part of your program do the following:
a. Instantiate (create objects from GeoPoint) the following two locations:
i. Dallas: 35.106766, -106.629181
ii. Austin: 39.742043, -104.991531
Name the objects Dallas and Austin
Test user location, for example, Santa Fe, NM
Santa Fe, NM: 36.89532386641793, -104.43291016842771
b. Use the SetPoint and SetDescription methods to set the Dallas and Austin locations and descriptions.
c. Inside a loop do the following:
i. Ask the user for their location. You can ask for coordinates in separate inputs or ask them for their coordinates in one input with each element separated by a coma.
ii. Use Dallas and Austin Distance method to find the distance from each to the users location
distanceToDallas=Dallas.Distance(lat, long)
distanceToAustin = Austin.Distance(lat, long)
iii. Tell the user which point they are closest to in this format:
You are closest to
iv. Ask Do another distance calculation (y/n)? and repeat loop if they respond with y; break out of loop for any other response
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
