Question
Write a Map class that is composed of a Location class. Location class has three private variable string nameOfCity, double variables, latitude and longitude. It
Write a Map class that is composed of a Location class.
Location class has three private variable string nameOfCity, double variables, latitude and longitude.
It has a constructor to initialize these and also the usual getters.
It has three functions: string toString() which prints
:double getFlyingTime(Location l) which returns the flying time between this
and location l. It uses the formula that time = distance/speed. speed = 673 miles/hour. No need to convert to minutes.
: double getDistance(Location l). This method is used by getFlyingTime.
The Map class has function double getFlyingTime(string l, string r); It returns -1 if the two cities are not found in its database.
Map class has a vector of 4 location objects.
The driver program creates the map by providing the locations to the Map.
Once the Map is created, it asks the user for two cities. If the cities are found, it returns the flying distance otherwise it says cities not found. The cities have first letter capitalized and rest small
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