Re: help creating a class
Couple of problems I can see right away.
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) // why have paramaters if you're not going to use them?
{
dollars = 0.00;
cents = .00;
}
void gaspump::ResetFuelPumped(float gals)
{
gallons = gal; // huh? why have this line?
gallons = 0.00;
}
float gaspump::DisplayFuelCharges(char grade, int octane, int gal, float charges)
{
if (grade ++ "L") // I think this typo is pretty obvious
{
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;
}
}