Question: Every function except the main function must have a brief comment that discusses the purpose of the function, the input parameters, and outputs and/or return
Every function except the main function must have a brief comment that discusses the purpose of the function, the input parameters, and outputs and/or return value. Please do this for the functions in the odometer.cpp file below. Also be sure to include which are mutator functions, and which are accessor functions.
Example:
Description: isAlarmTime() checks to see if the alarm time is equal to the current * time. The inputs are the alarm hour and alarm minute along with the * current hour and current minute. True is returned when they are equal and * false otherwise.
bool isAlarmTime(int ahr, int amn, int hr, int mn)
{
bool ringAlarm = false;
if ((ahr == hr) && (amn == mn))
ringAlarm = true;
return ringAlarm; }
-------------------------------------------------------------------------------------------------------------
odometer.cpp file:
#include
double odometer::miles = 0;
//-------------------------------------------------------------------------- /* */ odometer::odometer(double milesDriven, double noOfGallonsUsed) { miles += milesDriven; gallons = noOfGallonsUsed; }
//-------------------------------------------------------------------------- /* */ double odometer::getMilesDriven() { return miles; }
//-------------------------------------------------------------------------- /* */ double odometer::getGallonsOfgasConsumed() { return gallons; }
//-------------------------------------------------------------------------- /* */ void odometer::reset() { miles = 0; }
//-------------------------------------------------------------------------- /* */ void odometer::resetGallons() { gallons = 0; }
//-------------------------------------------------------------------------- /* */ void odometer::setMPG(double mpg) { MPG = mpg; }
//-------------------------------------------------------------------------- /* */ void odometer::setGallons(int gallons) { gallons = gallons; }
//-------------------------------------------------------------------------- /* */ void odometer::setMiles(int miles) { miles = miles; }
//-------------------------------------------------------------------------- /* */ double odometer::getMPG() { return miles / gallons; }
odometer.h file:
#include
class odometer { public: odometer(double milesDriven,double noOfGallonsUsed); double getMilesDriven(); double getGallonsOfgasConsumed(); void reset(); void resetGallons(); void setMPG(double mpg); void setGallons(int gallons); void setMiles(int miles); double getGallons(); double getMPG();
private: // Declaring variables double gallons; static double miles; double MPG; };
#endif // ODOMETER_H
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
