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 nearby)getters 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 (non-abstract) 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 - I'm 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: $2.20cost per mile: $1.29minimum fare:$7.65
The DoordashRide class has a concrete implementation of calculateFare() that includes:
base fare: $1.56cost per mile: $0.83minimum fare: $5.30service fee: $3.25
About the "minimum fare" for either case above: if the base_fare + cost_per_mile * distance is less than minimum_fare, 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 well-formatted 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 -8.6
Location - Los Angeles, distance Traveled -13.6
Location - Boston, distance Traveled -12.1
Location - Miami , distance traveled. -8.7
Location - Chicago, distance Traveled -11.1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!