Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your solution should for this assignment should consist of five (5)files: ============================================== FuelGauge.h (class specification file) FuelGauge.cpp (class implementation file) Odometer.h (class specification file) Odometer.cpp

Your solution should for this assignment should consist of five (5)files:

==============================================

FuelGauge.h (class specification file)

FuelGauge.cpp (class implementation file)

Odometer.h (class specification file)

Odometer.cpp (class implementation file)

200_assign6.cpp (application program)

=================================================

For your sixth programming assignment, you will be implementing a program that uses two(2)classes that work together to simulate a cars fuel gauge and odometer. The classes you will design are:

TheFuelGaugeClass: This class will simulate a fuel gauge. Its responsibilities are

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

To report the cars current amount of fuel, in gallons.

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

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.

TheOdometerClass: This class will simulate the cars odometer. Its responsibilities are:

To know the cars current mileage.

To report the cars current mileage.

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.

To be able to work with aFuelGaugeobject. It should decrease theFuelGaugeobjects current amount of fuel by 1 gallon for every 24 miles traveled. (The cars fuel economy is 24 miles per gallon.)*

The FuelGaugeclass should have at least one constructor, and the appropriate member functions to get the number of gallons, increment the number of gallons, and decrement the number of gallons.

The odometer class should have at least one constructor, and the appropriate member functions to get the mileage and increment the mileage (unfortunately you cannot decrement the mileage!).

*In the odometer class, you can have a member variable that is a pointer to a FuelGauge object. This is how you can establish a relationship between the two classes that allow them to work together. For every mile the car is driven, the odometer is increased by 1, and for every 24 miles the car is driven, the number of gallons is reduced by one.

So in the Odometer class, one of the private member variables should be of type fuel gauge* (pointer to a FuelGauge object).

Demonstrate the two classes by creating instances(objects)of each. Simulate filling the car up with fuel, and then 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.

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

5. A review of the key behaviors is included.

Answered: 1 week ago