I am trying to creat a gaspump class. I need to creat the functions, reset fuel pump, reset fuel charge, display fuel charges, display fuel pumped, pump status ( on or off), fuel grade( leaded, unleaded, or diesel), and octane ratings. I am unsure of how to write the functions. I took a stab at it. I also wanted to know about reating objects. Should they be pump1, pump2 etc.. or the cars that use the pumps like Nissan, volvo, etc... Any help would anyone could give would ease my stress greatly. Here is the class that I created:
Code:
class gaspump
{
private:
void ResetFuelCharges(int bills, int coins);
void ResetFuelPumped(int gal);
float gallons;
float dollars;
float cents;
public:
float DisplayFuelCharge(char grade, int octane, int gal, float charges);
float DisplayFuelPumped;
bool PumpStatus;
char FuelGrades;
int OctaneRatings;
};
and the functions that I done so far:
void gaspump::ResetFuelCharges(float bills, float coins)
{
dollars = 0.00;
cents = .00;
}
void gaspump::ResetFuelPumped(float gals)
{
gallons = gal;
gallons = 0.00;
}
float gaspump::DisplayFuelCharges(char grade, int octane, int gal, float charges)
{
if (grade ++ "L")
{
charges = 2.00 * gallons;
return charges;
}
if (grade =="D")
{
charges = 2.25 * gallons;
return charges;
}
if (grade == "U") && (octane == "R")
{
charges = 1.40 * gallons;
return charges;
}
if (grade =="U") && (octane == "S")
{
charges = 1.50 * gallons;
return charges;
}
else
if (grade == "U") && (octane == "G")
{
charges = 1.75 * gallons;
return charges;
}
}