Question: Create an abstract superclass called Ride: The Ride will implement the Comparable interface. The Ride will have: attributes of destination location and distance traveled (
Create an abstract superclass called Ride:
The Ride will implement the Comparable interface.
The Ride will have:
attributes of destination location and distance traveled in miles as attributes FYI the distance is from the airport in the city to a popular hotel nearbygetters and setters as appropriate for the attributesabstract method calculateFare this method calculates and returns the fare. It DOES NOT assign a value to an attribute.
Create two concrete nonabstract classes called GrubhubRide and DoordashRide
You may consider using a class to contain the constants in the calculations below.
I know that the constants below vary by the city around the country Im making this a bit easier to code. There are more costs associated with Grubhub, and Doordash rides again, making it a bit easier to code.
The GrubhubRide class has a concrete implementation of calculateFare that includes:
base fare: $cost per mile: $minimum fare:$
The DoordashRide class has a concrete implementation of calculateFare that includes:
base fare: $cost per mile: $minimum fare: $service fee: $
About the "minimum fare" for either case above: if the basefare costpermile distance is less than minimumfare, then the cost for the ride should be minimum fare.
Use the Comparable interface to compare Ride objects by cost in the same city.
Write a driver for this application that will:
create an ArrayList of Ride objects grubhub and Doordashrides
display all rides in a wellformatted table
list all rides by city ask your user for city, your program will display the rides in that city include the type of ride grubhub or Doordash use instanceof to display the type
display the less expensive ride in the city entered by your user by cost and by type.
Location New York distance Traveled
Location Los Angeles, distance Traveled
Location Boston, distance Traveled
Location Miami distance traveled.
Location Chicago, distance Traveled
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
