Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2: Consider the following UML diagram and the class User, which can be part of a ride sharing app. Implement the class Ride, with

image text in transcribed
Question 2: Consider the following UML diagram and the class User, which can be part of a ride sharing app. Implement the class Ride, with the following specifications: 1. Customers are charged when the ride starts. If the customer does not have enough balance, the ride cannot start. The cost of the ride is the distance multiplied by cost_per_mile (You may make cost_per_mile constant, for example 5.0) 2. At the end of a ride, the trip distance should be added to the miles of both the customer and driver. 50% of the ride cost should be deposited to the driver. You may use the main method below and the expected output to check your implementation. Ride .distance: int teost per mile: double +Rider User User, int) getRideCost double stavoid +end/:void String String puble SLEE D les". balance balances public static void main(String[] args) { User cl=new User ("Iman", 123); cl.deposit (50); User dl=new User ("Gloria", 543); User d2-new User ("Moe", 674); Ride rl-new Ride (cl, d1,5); rl.start(); rl.end(); System.out.println(cl); System.out.println(dl); rl=new Ride (cl, d2, 20); ri.start(); rl.end(); System.out.println(cl); System.out.println(d2)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions