Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

car-instrument simulator design a set of classes that work together to simulate a car's fuel gauge and odometer. that classes you will design are as

car-instrument simulator

design a set of classes that work together to simulate a car's fuel gauge and odometer. that classes you will design are as follows:

the FuelGauge class: it will know the car's current amount of fuel in gallons

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? report the car's current amount of fuel in gallons

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? be able to increment the amount of fuel by 1 gallon. this simulates putting fuel in the car( max 15 gallons)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? be able to decrement the amount of fuel by 1 gallon if the fuel is greater than 0 gallons

Odometer class: simulates the cars odometer

? ? ? ? ? ? ? ? ? ? ? ? ?know the cars current mileage

? ? ? ? ? ? ? ? ? ? ? ? ?report the cars current mileage

? ? ? ? ? ? ? ? ? ? ? ? ?able to increment the current mileage by 1 mile with the max odometer reading of 999,999 then resets to 0

? ? ? ? ? ? ? ? ? ? ? ? ?able to work with the FuelGuage object by decreasing the amount of fuel by 1 gallon every 24 miles

demostrate the classes by creating instances of each. simulate filling the car up with fuel, then run a loop that increments the odometer until the car runs out of fuel. during each loop iteration, print the car's current mileage and amount of fuel.

Odometer + MAX_MILEAGE : int - 999999 + MPG : int = 24 - mileage : int setPOint: int fuelGauge : FuelGauge + Odometer(m : int, + getMileage() : int fg : FuelGauge) + incrementMileage: void FuelGauge + MAXGALLONS = 15 : int - gallons : int - + FuelGauge() + FuelGauge(g : int) + getGallons): int + incrementGallons) : void + decrementGallons) void

Odometer + MAX_MILEAGE: int = 999999 + MPG : int = 24 mileage: int - setPoint : int - fuelGauge : FuelGauge + Odometer(m: int, fg : FuelGauge) + getMileage(): int + incrementMileage(): void FuelGauge + MAX_GALLONS = 15 int - gallons : int + FuelGauge() + FuelGauge(g: int) + getGallons(): int + incrementGallons(): void + decrementGallons(): void

Step by Step Solution

3.50 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

class FuelGauge final static int MAXIMUMGALLONS 15 private int gallons public FuelGauge gallons 0 pu... 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

Managerial Accounting Creating Value in a Dynamic Business Environment

Authors: Ronald W. Hilton

9th edition

78110912, 978-0078110917

More Books

Students also viewed these Programming questions