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 CF
draft=0.70
you should get 166.9 W
Solution
BikeRacer.h
===========
#ifndef BIKE_RACER_H
#define BIKE_RACER_H
class Bike
{
private :
float m_M;
float m_Cr;
public :
// constructors
void Bike();
void Bike(float M, float Cr);
//Access methods
void setBikeMass(float M);
float getBikeMass();
void setBikeCR(float Cr);
float getBikeCR();
float power();
};
class Racer
{
private :
float m_M;
float m_k;
float m_v;
float m_draft;
public :
// constructors
void Racer();
void Racer(float M, float k, float v, float draft);
//Access methods
void setRiderMass(float M);
float getRiderMass();
float TotalEnergy(float distance);
void setK(float k);
float getK();
void setVelocity(float v);
float getVelocity();
void setCDraft(float draft);
float getCDraft();
};
#endif
BikeRacer.cpp
=============
#include \"BikeRacer.h\"
using namespace std;
void Bike::Bike()
{
// default constructor
}
void Bike::Bike(float M, float Cr)
{
m_M = M;
m_Cr = Cr;
}
void Bike::setBikeMass(float M)
{
m_M = M;
}
float Bike::getBikeMass()
{
return m_M;
}
void Bike::setBikeCR(float Cr)
{
m_Cr = Cr;
}
float Bike::getBikeCR()
{
return m_Cr;
}
void Racer::Racer()
{
// default constructor
}
void Racer(float M, float k, float v, float draft)
{
m_M = M;
m_k = k;
m_v = v;
m_draft = draft;
}
void Racer::power(){
return m_M * m_Cr;
}
void Racer::setRiderMass(float M)
{
m_M = M;
}
float Racer::getRiderMass()
{
return m_M;
}
void Racer::setK(float k)
{
m_k = k;
}
float Racer::getK()
{
return m_k;
}
void Racer::setVelocity(float v)
{
m_v = v;
}
float Racer::getVelocity()
{
return m_v;
}
void Racer::setCDraft(float draft)
{
m_draft = draft;
}
float Racer::getCDraft()
{
return m_draft;
}
float Racer::TotalEnergy(float distance){
return m_M * m_v * m_draft*distance;
}



