Question: 7 . 1 9 LAB * : Program: Fancy car Program Specifications Write a FancyCar class to support basic operations such as drive, add gas,
LAB: Program: Fancy car
Program Specifications Write a FancyCar class to support basic operations such as drive, add gas, honk horn, and start engine. FancyCar.h declares the functions necessary to complete the exercise. FancyCar.cpp provides the function stubs. Follow each step to gradually complete all functions in FancyCar.cpp
Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. The main function includes basic function calls. Add statements in main as functions are completed to support development mode testing.
Step In FancyCar.h declare private members for miles driven as shown on the odometer int gallons of gas in tank double miles per gallon or MPG double driving capacity double and car model string Note the provided constant variable indicates the gas tank capacity of gallons.
Step pts Complete the default constructor by initializing the odometer to five miles, tank is full of gas, miles per gallon is and the model is "Old Clunker". Complete the second constructor by passing the model string and miles per gallon double and initializing all other private members the same as the default constructor. Complete the accessor functions to check the odometer, check the gas guage, get the model, and get the miles per gallon. Submit for grading to confirm tests pass.
Step pt Complete the HonkHorn function to output the car model. If the car model is:
Honda Civic
the HonkHorn function outputs:
The Honda Civic says beep beep!
Submit for grading to confirm tests pass.
Step pt Complete the Drive function. Miles driven should increase by parameter distance, and the amount of gas should decrease by distance MPG Variables are only updated if parameter distance is positive. Submit for grading to confirm tests pass.
Step pts Complete the AddGas function. Increase gas tank by parameter amount only if parameter is positive. Set gas tank to FULLTANK if too much gas was added. Submit for grading to confirm tests pass.
Step pts Update the Drive function to identify if the car runs out of gas. If so the parameter distance will not be achieved, and the gas tank will have gallons. Ex: Drive will not be possible with only three gallons of gas and MPG of The maximum driving distance is miles with three gallons of gas and MPG of Therefore, the odometer will only increase by instead of the requested and the gas tank will have gallons not a negative amount Submit for grading to confirm tests pass.
Step pts Add a boolean private data member in FancyCar.h to indicate if the car engine is on or off. Complete the StartEngine function to set the boolean variable to true. Complete the StopEngine function to set the boolean variable to false. Update the constructors to start with the engine off. Update the Drive function to only update private members if the engine is on and the engine turns off if the car runs out of gas. Update the AddGas function to only add gas if the engine is off. Submit for grading to confirm all tests pass.
use the given cod#ifndef FANCYCARH
#define FANCYCARH
#include
#include
using namespace std;
const int FULLTANK ;
#include
#include
class FancyCar
public:
Default constructor
FancyCar;
Constructor string make, double mpg
FancyCarstring carMake, double carMpg;
Return car model
string GetModel;
Return miles per gallon MPG
double GetMPG;
Return miles on odometer
int CheckOdometer;
Return amount of gas in tank
double CheckGasGauge;
Honk horn
void HonkHorn;
Drive car requested miles but check for enough
gas and check for positive value
void Driveint milesToDrive;
Add gas to tank Check for positive value.
void AddGasdouble amtToAdd ;
Set boolean variable to true
void StartEngine;
Set boolean variable to false
void StopEngine;
private:
TODO: Declare private data members
;
#endife
Main.cpp
#include "FancyCar.h
#include
int main
FancyCar car;
FancyCar carHonda Civic", ;
std::cout "Car Model: cargetModel MPG: cargetMPG std::endl;
std::cout "Car Model: cargetModel MPG: cargetMPG std::endl;
carHonkHorn;
carHonkHorn;
carStartEngine;
carDrive;
std::cout "Car Odometer: cargetOdometer Gas Tank: cargetGasTank std::endl;
carAddGas;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
