You will create a class where the class descriptions are pla
You will create a class where the class descriptions are placed in a file named BikeRacer.h and a file named BikeRacer.cpp will contain the implementation of the methods for those classes. COG will use these files to test your implementation of the classes. Create a class called Racer. The class Racer will contain private floating point variables for data listed below. All these data members should be private, with public access methods to get and set the values. Racer constructor will need to initialize all the member variables. Mass of the bike in kg Coefficient related to the resistance of the bike on the road Mass of the rider in kg Velocity in m/s Coefficient related to rider position(K) Coefficient of drafting //Access methods Racer::setBikeMass(...) Racer::getBikeMass() Racer::setBikeCR(...) Racer::getBikeCR() Racer::setRiderMass (...) Racer::getRiderMass() Racer::setCDraft(...) Racer::getCDraft() Racer::setK (...) Racer::getK() Racer::setVelocity (...) Racer::getVelocity() The power output for a cyclist (measured in Watts) can be calculated from the power needed to overcome air resistance and the power needed to overcome rolling resistance. Write a method Power() for Racer to calculate the floating point value for power required per second based on current racer and racer’s bike settings. Write a method to calculate the total power required to travel a given distance in kilometers. TotalEnergy(float distance) will return the floating point value for total energy as specified in the previous assignment’s write up. Use the following values to test your classes: Bike M =15 Cr = 0.001 Racer M = 63 k = 0.18 v = 10.8 CFdraft = 0.70 you should get 166.9 W
Solution
BikeRacer.h
-----------------------------
#ifndef BIKERACER_H
#define BIKERACER_H
class BikeRacer
{
private:
float Mass_Bike;
float CR_B;
float CR_R;
float Mass_Rider;
float Velocity;
float CDraft;
float power;
float energy;
public:
BikeRacer(float mass_b,float CR_b,float mass_r,float draft,float k,float velocity);
void setBikeMass(float mass_b);
void setBikeCR(float CR_b);
void setRiderMass (float mass_r);
void setCDraft(float draft);
void setK (float k);
void setVelocity(float velocity);
float getBikeMass() { return Mass_Bike; }
float getBikeCR(){ return CR_B; }
float getRiderMass(){ return Mass_Rider; }
float getCDraft(){ return CDraft; }
float getK() { return CR_R; }
float getVelocity(){ return Velocity; }
float Power(){ power=CDraft*Velocity; return power; } //your original logic goes here
float TotalEnergy(){energy=Mass_Bike*CR_B+Mass_Rider*CR_R+Velocity*CDraft; return energy; } //your original logic goes here.
};
#endif
-----------------------BikeRacer.cpp-----------------------
#include \"BikeRacer.h\"
#include <iostream>
// Date constructor
BikeRacer::BikeRacer(float mass_b,float CR_b,float mass_r,float draft,float k,float velocity)
{
setBikeMass(mass_b);
setBikeCR(CR_b);
setRiderMass (mass_r);
setCDraft(draft);
setK (k);
setVelocity(velocity);
}
void BikeRacer::setBikeMass(float CR_b)
{
CR_B=CR_b;
}
void BikeRacer::setBikeCR(float CR_b)
{
CR_B=CR_b;
}
void BikeRacer::setRiderMass(float mass_r)
{
Mass_Rider=mass_r;
}
void BikeRacer::setCDraft(float draft)
{
CDraft=draft;
}
void BikeRacer::setK(float k)
{
CR_R=k;
}
void BikeRacer::setVelocity(float velocity)
{
Velocity=velocity;
}
----------------------------examplemain-----------------------------
#include \"BikeRacer.h\"
#include <iostream>
using namespace std;
int main()
{
float a=3.78,b=0.56,c=0.78,d=1.09,e=9.09,f=4.99,g=0.89;
BikeRacer br(float(a),float(b),float(c),float(d),float(e),float(f));
//additional program...
return 0;
}

