Menu

[Solved]-Using C Create Car Instrument Simulator Car Instrument Simulator Create Following Classes Q37233540

(Using C++ create a Car Instrument Simulator)

Car Instrument Simulator

Create the following classes: Car, Odometer, FuelGauge.

The Car class allows for the instantiation of a Car object.

The Car object will contain (via composition) an Odometerobject, and a FuelGauge object.

The Car object will also include “make”, “model”, and “color” asstring properties (instance variables).

In the Car constructor method, you will create a FuelGaugeobject, passing 15 as an argument into the FuelGauge constructorindicating the number of gallons.

In the Car constructor method, you will create an Odometerobject, passing 0 and the address of the FuelGauge object asarguments to the Odometer constructor, indicating the number ofmiles driven and the address of the FuelGauge objectrespectively.

The Car class will have a “drive(int miles)” method.

The Odometer object will contain a pointer to a FuelGaugeobject.

The Odometer object will contain a “milesDriven” instancevariable.

The Odometer object will have an “incrementMileage()”method.

The implementation of the Odometer incrementMileage method willbe such that if the fuel level is greater than zero, the Odometerincrements its mileage instance variable by 1. Also, at everyinterval of GAS_MILEAGE (a constant that specifies the miles pergallon), and if the FuelGauge’s fuelLevel is greater than zero, theOdometer will call the decreaseFuelLevel() method on the FuelGaugeobject.

The FuelGauge object will have a “decreaseFuelLevel()” method.

The FuelGauge object will contain a “fuelLevel” instancevariable.The FuelGauge object will have a “getFuelLevel()” methodthat returns the current value of the fuelLevel instancevariable.

The FuelGauge object will have a “decreaseFuelLevel(intgallons)” method.

The implementation of the FuelGauge decreaseFuelLevel methodwill be such that the FuelGauge decrements the fuelLevel instancevariable by the specified number of gallons. Do not decrease thefuelLevel to a negative value.

The implementation of the Car “drive(int miles)” method will besuch that it has a loop wherein…

while you’ve driven less then the number of miles specified by the”drive” method parameter value (make it 500) and the fuel level isgreater than zero,call the incrementMileage method on the Odometerobject.

When the car stops driving because it has run out of fuel, displaythe number of miles driven.

Deliverables:

7 files: a .h file for each class, a .cpp file for each class,and one .cpp file for your main function.

Expert Answer


Answer to (Using C++ create a Car Instrument Simulator) Car Instrument Simulator Create the following classes: Car, Odometer, Fuel… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *