Answered step by step
Verified Expert Solution
Question
1 Approved Answer
** USING PYTHON You are going to define a class to keep track of a point in space, its description and provide it the capability
- ** USING PYTHON
- You are going to define a class to keep track of a point in space, its description and provide it the capability to figure out its distance from another point. You may be able to re-use some of the code from your previous work.
- In your program define a class called GeoPoint that will have the following:
- 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 .
- A SetPoint(self, lat, lon) method that will set the values of self.lat, self.lon
- A GetPoint(self) method that will return a tuple or list with self.lat, self.lon.
- 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.
- A SetDescription(self, description) method that will set the objects self.description attribute (variable).
- A GetDescription(self) method that will return the objects seldescription attribute.
- In the main part of your program do the following:
- Instantiate (create objects from GeoPoint) the following two locations:
- Albuquerque: 35 6' 24.3576'' N, 106 37' 45.0516'' W; 35.106766, -106.629181
- Denver: 39 44' 31.3548'' N, 104 59' 29.5116'' W; 39.742043, -104.991531
- Instantiate (create objects from GeoPoint) the following two locations:
Name the objects ABQ and DENVER
- Use the SetPoint and SetDescription methods to set the ABQ and DENVER locations and descriptions.
- Inside a do another loop do the following:
- 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.
- Use ABQ and DENVER Distance method to find the distance from each to the users location
distanceToOne = ABQ.Distance(lat, lon)
distanceToTwo = DEN.Distance(lat, lon)
- Tell the user which point they are closest to in this format:
You are closest to
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started