Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE JAVE PLEASE! DO NOT COPY FROM OTHER WEBSITE For this part, you will design a set of classes that work together to simulate a

USE JAVE PLEASE! DO NOT COPY FROM OTHER WEBSITE

For this part, you will design a set of classes that work together to simulate a cars fuel gauge and odometer. The classes you will design are the following:

The FuelGauge class: This class will simulate a fuel gauge. Its responsibilities are as follows:

o To know the cars current amount of fuel, in gallons

o To report the cars current amount of fuel in gallons

o To be able to increment he amount of fuel by 1 gallon. This simulates putting fuel in the car (The car can hold max 15 gallons)

o To be able to decrement the amount of fuel by 1 gallon, if the amount of fuel is greater than 0 gallons. This simulates burning fuel as the car runs.

The Odometer class: This class will simulate the cars odometer. Its responsibilities are as follows:

o To know the cars current mileage

o To report the cars current mileage

o To be able to increment the current mileage by 1 mile. The maximum mileage the odometer can store is 999,999 miles. When this amount is exceeded, the odometer resets the current mileage to 0

o To be able to work with a FuelGauge object. It should decrease the FuelGuage objects current amount of fuel by 1 gallon for every 22 miles travelled. (The cars fuel economy is 22 miles per gallon)

Demonstrate the classes by creating instances of each. Simulate filling the car up with fuel, and the run a loop that increments the odometer until the car runs out of fuel. During each loop iteration, print the cars current mileage and amount of fuel.

Each part should have its code files in its respective package mentioned above

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

e. What do you know about your ethnic background?

Answered: 1 week ago

Question

b. Why were these values considered important?

Answered: 1 week ago