Question
Can you help me with this exercise. I already have some codes here: Thanks. FuelTank.h #pragma once class FuelTank { public: FuelTank(); // default constructor
Can you help me with this exercise.
I already have some codes here:
Thanks.
FuelTank.h
#pragma once
class FuelTank
{
public:
FuelTank(); // default constructor (capacity = 0.0, level = 0.0)
FuelTank(double cap); // construct setting fuel capacity (level = 0.0)
FuelTank(double cap, double lvl); // construct setting fuel capacity and level
void setCapacity(double amt); // set or change capacity
double addFuel(double amt); // add to level - return amount added
double useFuel(double amt); // subtract from level - return amount used
double fillUp(); // return amount used
double getCapacity() const; // return fuel tank capacity
double getLevel() const; // return current fuel level in tank
double getUnusedCapacity() const; // return available (unused) fuel capacity
void displayFuelTankInfo() const; // show capacity, current level, unused capacity
private:
bool isFull() const; // return true if tank is full, else false
bool isEmpty() const; // return true if tank is empty, else false
double capacity; // maximum capacity of fuel tank - gallons
double level; // current level of fuel in tank - gallons
};
Assign07-FuelTankClass.cpp
// Assign07-FuelTankClass.cpp : Defines the entry point for the console application.
//
//
#include "stdafx.h"
#include "FuelTank.h"
#include
#include
#include
using namespace std;
void displayActualAdded(double actualAdded);
void displayActualUsed(double actualAdded);
int main()
{
double actualAmount;
FuelTank tank01;
FuelTank tank02(25.0);
FuelTank tank03(20.0, 12.0);
tank01.displayFuelTankInfo();
tank01.setCapacity(30.0);
tank01.displayFuelTankInfo();
tank01.addFuel(11.8);
tank01.useFuel(5.5);
tank01.displayFuelTankInfo();
actualAmount = tank01.fillUp();
displayActualAdded(actualAmount);
tank01.displayFuelTankInfo();
cout
tank02.displayFuelTankInfo();
actualAmount = tank02.addFuel(500.0);
displayActualAdded(actualAmount);
tank02.displayFuelTankInfo();
actualAmount = tank02.useFuel(200.0);
displayActualUsed(actualAmount);
tank02.displayFuelTankInfo();
cout
tank03.displayFuelTankInfo();
tank03.addFuel(6.3);
tank03.displayFuelTankInfo();
tank03.useFuel(11.2);
tank03.displayFuelTankInfo();
tank03.addFuel(12.8);
tank03.displayFuelTankInfo();
tank03.useFuel(19.5);
tank03.displayFuelTankInfo();
actualAmount = tank03.fillUp();
displayActualAdded(actualAmount);
tank03.displayFuelTankInfo();
cout
system("pause");
return 0;
}
void displayActualAdded(double actualAdded)
{
cout
cout
}
void displayActualUsed(double actualUsed)
{
cout
cout
}
I need code for FuelTank.cpp
yyyy- --> BA CSIS 223 C++ Object-Oriented Programming Assign07- FuelTankClass Fuel Tank Class Create the new project Assign07-FuelTankClass. Click the Projecr tab and select Add Class.. to add the new class FuelTank, creating the header file FuelTank.h and the implementation file FuelTank.cpp The FuelTank class will conform to this UML specification: FuelTank data members (private) capacity: double evel double member functions: +setCapacity (double) +addFuel (double) +useFuel (double) +fillUp() : void mutator functions : double : double : double const : double const: double setters (public) +getcapacity() +getLevel): +getUnusedCapacity) const: double accessor functions getters (public) helper functions displayFuelTankInfo() const: void isFull() isEmpty() const: bool const : bool (private) (private) The class also needs three constructors- a default constructor (setting both the capacity and level to 0.0) and two parameterized constructors, one taking just a single argument (a double) to set the overall fuel tank capacity (while assigning 0.0 to the fucl level) and another constructor that accepts two arguments (both doubles) that together set both the capacity and the level Select the C:VCProjectsOOP folder and copy the contents of FuelTanklHeader.txt into the FuelTank.h hcader file. This will serve as the programming interface for the FuelTank class. #pragma once class FuelTank public: FuelTank): FuelTank (double cap); FuelTank(double cap, double lvl); default constructor (capacity -0.0, level -0.0) # construct setting fuel capacity (level 0.0) void setCapacity (double amt); double addFuel (double amt); double useFuel (double amt); double fillUp(; construct setting fucl capacity and level ff set or change capacity ff add to fuel level - retum amount added ff subtract from fuel level - return amount used f return amount needed to fill fuel tank const; return fuel tank capacity double getCapacity() double getLevel() double getUnusedCapacity) const; return unused (available) tank capaci voi id displayFuelTankInfo() const; i display capacity, level, unused, FULL or EMPTY retum true if tank is full, else false retum true if tank is empty, else false maximum capacity of fuel tank - gallons f current level of fuel in tank-gallons private const; const; bool isFull() bool isEmpty() double capacity; double level; hStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started