Question: 4 . You are creating a Java program for a ride - sharing service called Uber, where users can request rides and drivers can accept
You are creating a Java program for a ridesharing service called Uber, where users can request rides and drivers can accept them. Each ride has a unique ID the pickup location, the dropoff location, the distance of the ride in miles the duration of the ride in minutes the cost of the ride, and the driver's name.
Your task is to create a Java class called "RideRequest" that can represent a single ride request. The class should have the following:
a Private instance variables to store the ride ID pickup location, dropoff location, distance, duration, cost, and driver's name.
b A constructor that takes the ride ID pickup location, and dropoff location as parameters and initializes the instance variables distance duration, cost, and driver's name should be set to or an empty string
c Getter and setter methods for all the instance variables.
d A method called "calculateRideCost that calculates the cost of the ride based on the distance and duration eg $ per mile $ per minute
e A method called "assignDriverString driverName that sets the driver's name for the ride.
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
