A class RentedVehicle that has: 1.One private instance variable baseFee of type double 2.One constructor to initialize the instance variable 3. One instance method getCost () that returns the base fee - Accessor methods for the instance variables A subclass FuelVehicle that: 1.has one additional private instance variable nbKms indicating the total number of kilometers traveled. 2. one constructor to initialize the instance variables. 3. one instance method getMileageFees to return the fees due to mileage based on the following:

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

USE C++ AND Concept of inheritance for the program.

A class RentedVehicle that has:
1.One private instance variable baseFee of type double
2.One constructor to initialize the instance variable
3. One instance method getCost () that returns the base fee - Accessor methods for the
instance variables
A subclass FuelVehicle that:
1.has one additional private instance variable nbKms indicating the total number of
kilometers traveled.
2. one constructor to initialize the instance variables.
3. one instance method getMileageFees to return the fees due to mileage based on the
following:
If nbKms<100 mileagefees=0.2*nbkms
If 100<=nbKms<=400 mileagefees=0.3*nbkms
If nbKms>400 mileagefees=0.3 times 400 plus 0.5times the extra kilometers above 400.
- accessor methods
A Car class which is a subclass of FuelVehicle that:
1. has one additional private instance variable nbSeats
2. has one constructor to initialize the instance variables
3.overrides getCost method by adding nbseats*baseFee to mileageFees
4.accessors
A Truck class which is a subclass of FuelVehicle that:
1. has one private instance variable capacity
2. has one constructor to initialize the instance variables
3.overrides getCost method by adding baseFee*capacity to mileageFees
4. accessors
A Bicycle class that extends RentedVehicle that:
1. has one additional private instance variable nbDays indicating the number of days it
is rented.
2. has one constructor to initialize the instance variables
3. overrides getCost method to return baseFee * nbDays
4. accessors
Note: Implement all five classes with their accessor and mutator methods.
EXPECTED OUTPUT:
Write a MAIN class that generates 6 objects randomly from either a Car, or a Truck, or a
Bicycle class. Prints the following information.
1. if the object is a car print its name and the number of seats and cost.
2. if it is a Truck, print its name and capacity and cost.
3. if it is a Bicycle, print its name and how many days it is rented and cost.
Transcribed Image Text:A class RentedVehicle that has: 1.One private instance variable baseFee of type double 2.One constructor to initialize the instance variable 3. One instance method getCost () that returns the base fee - Accessor methods for the instance variables A subclass FuelVehicle that: 1.has one additional private instance variable nbKms indicating the total number of kilometers traveled. 2. one constructor to initialize the instance variables. 3. one instance method getMileageFees to return the fees due to mileage based on the following: If nbKms<100 mileagefees=0.2*nbkms If 100<=nbKms<=400 mileagefees=0.3*nbkms If nbKms>400 mileagefees=0.3 times 400 plus 0.5times the extra kilometers above 400. - accessor methods A Car class which is a subclass of FuelVehicle that: 1. has one additional private instance variable nbSeats 2. has one constructor to initialize the instance variables 3.overrides getCost method by adding nbseats*baseFee to mileageFees 4.accessors A Truck class which is a subclass of FuelVehicle that: 1. has one private instance variable capacity 2. has one constructor to initialize the instance variables 3.overrides getCost method by adding baseFee*capacity to mileageFees 4. accessors A Bicycle class that extends RentedVehicle that: 1. has one additional private instance variable nbDays indicating the number of days it is rented. 2. has one constructor to initialize the instance variables 3. overrides getCost method to return baseFee * nbDays 4. accessors Note: Implement all five classes with their accessor and mutator methods. EXPECTED OUTPUT: Write a MAIN class that generates 6 objects randomly from either a Car, or a Truck, or a Bicycle class. Prints the following information. 1. if the object is a car print its name and the number of seats and cost. 2. if it is a Truck, print its name and capacity and cost. 3. if it is a Bicycle, print its name and how many days it is rented and cost.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT