Answered step by step
Verified Expert Solution
Link Copied!

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

  1. ** USING PYTHON
  2. 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.
  3. In your program define a class called GeoPoint that will have the following:
    1. 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 .
    2. A SetPoint(self, lat, lon) method that will set the values of self.lat, self.lon
    3. A GetPoint(self) method that will return a tuple or list with self.lat, self.lon.
    4. 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.
    5. A SetDescription(self, description) method that will set the objects self.description attribute (variable).
    6. A GetDescription(self) method that will return the objects seldescription attribute.
  4. In the main part of your program do the following:
    1. Instantiate (create objects from GeoPoint) the following two locations:
      1. Albuquerque: 35 6' 24.3576'' N, 106 37' 45.0516'' W; 35.106766, -106.629181
      2. Denver: 39 44' 31.3548'' N, 104 59' 29.5116'' W; 39.742043, -104.991531

Name the objects ABQ and DENVER

  1. Use the SetPoint and SetDescription methods to set the ABQ and DENVER locations and descriptions.
  2. Inside a do another loop do the following:
    1. 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.
    2. 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)

  1. Tell the user which point they are closest to in this format:

You are closest to which is located at

  1. 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

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago