Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
I am creating a class using python, I am stuck with inserting the functions as I have run across some errors. I will attach my program and the instructions.
- In your program define a class called GeoPoint that will have the following:
- A constructor __init__(self, lat=0, lon=0,description=’TBD’) that will initialize the class variables called: self.lat, self.lon, and self.description.
- A SetPoint(self, point) method that takes an individual points coordinates as a single sequence and sets them to self.lat, self.long. E.g:
self.lat = point[0]
self.lon =point[1]
- A GetPoint(self) method that will return a tuple or list with self.lat, self.lon.
- A CalcDistance(self, lat, lon) method that will figure out the distance between the object’s self.lat, self.lon and lat, lon parameters passed in.
- A CalcDistancePoint(self, point) method that takes in a point (both coordinates at once, a data sequence, or GeoPoint object) that will figure out the distance between the object’s self.lat, self.lon and the lat and lon from the point.
- A SetDescription(self, description) method that will set the objects self.description attribute (variable).
- A GetDescription(self) method that will return the objects self.description attribute.
- Add a property: Point = property(GetPoint,SetPoint). Make sure GetPoint and SetPoint are the names you used for the get and set methods you already wrote for points.
- Add another property: Description = property(GetDescription, SetDescription). Make sure GetDescription and SetDescription are the names you used for the get and set methods you already wrote.
- In the main part of your program do the following:
- Include the class.
- Instantiate three points.
- Use the constructor to set point1 coordinates and description. It should look something like the following but with your own coordinates and description:
point1 = GeoPoint(12.3456,-123.4567,'Loc1')
- Use a constructor without any arguments to instantiate the second point and use its properties to set its values. It should look something like the following but with your own coordinates and description:
point2 = GeoPoint()
point2.Point = 23.4567, -213.456
point2.Description = 'Loc2'
- For point3 use the SetPoint and SetDescription methods to set the points location and description. Make sure they have different coordinates and different descriptions. It should look something like the following but with your own coordinates and description:
point3 = GeoPoint()
point3.SetPoint((25.25,52.52))
point3.SetDescription(“Loc3”)
- Inside a “Do another (y/n)?” loop do the following:
- Create a fourth point by asking the user for their location. You can ask for coordinates in three inputs or ask them for their coordinates in one input with each element separated by a coma.
- Use the CalcDistance method to find the distance between point1 and a new latitude and longitude of your choosing. Then tell the user the coordinates for point1, the new latitude and longitude that was entered, and the distance between those coordinates. For example:
distanceToPoint1 = point1.CalcDistance(lat, lon)
- Use point2 and point3’s CalcDistancePoint method to find the distance from each point to the user’s location. Notice we are passing in the users point rather than the separate coordinates:
distanceToTwo = point2.CalcDistancePoint(userPoint)
distanceToThree = point3.CalcDistancePoint(userPoint)
- Tell the user which point they are closest to in this format:
You are closest to <description> which is located at <point’s lat and lon coordinates>
- Ask “Do another (y/n)?” and loop if they respond with ‘y’
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- in c++arrow_forwardCreate a C++ program that simulates a simple inventory management system for a store. The program should allow users to add new products, update product quantities, and generate reports. Follow these guidelines: 1. Implement a class called Product with attributes such as product ID, name, price, and available quantity. 2. Create a class called Inventory that manages an array of products. Include functions to: • Add new products to the inventory. Update the quantity of existing products. • Display details of all products in the inventory. Generate a report showing low-stock products (quantity less than a specified threshold). 3. Start by prompting the user to enter the initial number of products in the inventory. 4. Display a menu that allows users to choose from the following options: Add a new product. · Update product quantity. Display all products in the inventory. • Generate a low-stock report. • Exit the program. ● 5. For each operation, prompt the user for the necessary…arrow_forwardUsing C++ and Visual Studios Using your own creativity, make a set of class templates that have these features: For this class template, put everything in one place--do not declare the member functions and have separate definition of the member functions elsewhere. Keep them in one place. Include a private variable. Include a constructor that loads the private variable when constructed. Include a destructor that clears the private variable to zero. Include set and get functions to set and get the private variable.arrow_forward
- Using C++ and Visual Studios Using your own creativity, make a set of class templates that have these features: For this class template, put everything in one place--do not declare the member functions and have separate definition of the member functions elsewhere. Keep them in one place. Include a private variable. Include a constructor that loads the private variable when constructed. Include a destructor that clears the private variable to zero. Include set and get functions to set and get the private variable.arrow_forwardCan you help me with this code for C++ please: Modify the class Song you created for part 2 bydoing the following:(a) Add a default constructor that initializes the song to have invalid astitle and artist, and −1 as recording year.(b) Add a constructor Song(title) that initializes the song to thegiven title (that is, to the title given as argument). The artist andrecording year are initialized to unknown and −1, respectively. Theargument is a string.(c) Add a constructor Song(title, artist, year) that initializesthe song to the given title, artist and recording year. The first twoarguments are strings, the third one is an integer.(d) Replace the function equals(s1, s2) by a methodequals(other) that returns true if the receiver and theargument have the same title, artist and recording year.(e) Add a method less_than(other) that returns true if the title ofthe first song is less than the title of the second song. In case the titlesof the two songs are identical, the method returns true…arrow_forward!! E! 4 2 You are in process of writing a class definition for the class Book. It has three data attributes: book title, book author, and book publisher. The data attributes should be private. In Python, write an initializer method that will be part of your class definition. The attributes will be initialized with parameters that are passed to the method from the main program. Note: You do not need to write the entire class definition, only the initializer method lili lilıarrow_forward
- Which of the following statements about Python is true? A. Python does not support inheritance. B. Python does not support operator overloading. C. Python does not support garbage collection. D. Python supports function overloading. Another name for an attribute of an object is: A. method B. class C. integer D. instance variable Which of the following statements creates an object of the Rectangle class? A. myRectangle = createObject(Rectangle) B. myRectangle = createObject(Rectangle()) C. myRectangle = Rectangle() D. constructor(self) = Rectangle()arrow_forwardImportant requirements for all questions: • All data members must be declared as “private” • No global variable is allowed to be declared and used • Methods within the class and the requested functions cannot have “cin” or “cout” but it should make use of parameters and return value instead. • “cin” and “cout” should be done in main() or any testing functions • Make sure that you clearly show how the C++ class, its methods and all the functions are being called at least twice and print out its return value and its results properly.arrow_forwardNeed help with a C++ commenting question: Indicate where the different constructors, assignment operator= and desctructor will run with a comment under the relevant line of code. Start in main and use the following tags to indicate the function that will run: Default constructor <object name>String constructor <object name>Copy constructor <object name>Assignment operatorDestructor <object name>Substitute the variable name for the object constructed or destructed. Use a comma to separate if multiple functions are run on a line. Code to comment on: #include <iostream> 2 using namespace std; 3 4 class Student { 5 public: 6 friend Student OutputDuplicate (Student obj); // friend function 7 8 Student (); // Default constructor 9 10 Student (string n); // String constructor 11 12 Student (const Student & obj); // Copy constructor 13 14 Student& operator= (const Student &…arrow_forward
- I need help writing a C++ code. I need the code to be a class called date that has an integer data members to store month, day, and year. The class should have a three-parameter default constructor that allows the date to be set at the time a new Date Object is created. If the user creates a Date object without passing any arguments, or the values passed are invalid, the default values of 1,1,2001 (i.e, January 1, 2001) should be used. The class should have member functions to print the date in the following formats: 3/15/2020 March 15, 2020 15 March 2020 I also need the program to only accept real values for month and day. By this I mean month 1-12 and date 1- how ever long the month is.arrow_forwardFor C++ Programming II D.S. Malik Programming Exercise 10-16: Write the definition of a class swimmingPool, to implement the properties of a swimming pool. Your class should have the instance variables to store the length (in feet), width (in feet), depth (in feet), the rate (in gallons per minute) at which the water is filling the pool, and the rate (in gallons per minute) at which the water is draining from the pool. Add appropriate constructors to initialize the instance variables. Also, add member functions to do the following: determine the amount of water needed to fill an empty or partially filled pool, determine the time needed to completely or partially fill or empty the pool, and add or drain water for a specific amount of time, if the water in the pool exceeds the total capacity of the pool, output "Pool overflow" to indicate that the water has breached capacity. The header file for the swimmingPool class has been provided for reference. Write a program to test your…arrow_forwardThis is for C++ only, and I will be using visual studio as a compiler. You can use dummy variables that I will change later Write a class named Student that has member variables for the following data: First name, middle name, last name Address, city, state, and ZIP code Email address Student ID# Major The Student class should have a constructor that accepts an argument for each member variable and include accessors and mutators for each member variable. Next, write a class named Course that represents a course the student will take. The Course class should have member variables for the following data: Course ID number Name of the course Name of the instructor Grade earned Number of units The Course class should have a constructor that accepts an argument for each member variable. The Course class should also have accessor and mutator functions for each member variable. write a program that creates an instance of the Student class, initialized with sample data.…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education