Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class called FitnessMember that has only one variable, called name. The

ID: 3770131 • Letter: C

Question

Create a class called FitnessMember that has only one variable, called name. The person class should have a constructor with no parameters, a constructor with a parameter, a mutator function and an accessor function. Also, include a function to display the name. Define a class called Athlete which is derived from FitnessMember. An Athlete record has the Athlete's name (defined in the FitnessMember class) and ID number of type String. Define a class called Trainer whose objects are records for a fitness centers trainers. Derive this class from the class FitnessMember. A Trainer record has the Trainer's name (defined in the FitnessMember class) and a specialty as a String (for example, Weight, Aquatics, Cardio, Nutrition, etc.), and an training session fee (use the type double). A Billing object will contain an Athlete object and a Trainer object. Give all your classes a reasonable complement of constructors, and accessor and mutator functions. Write a main test program that creates at least two Athletes, at least two Trainers, and at least two Billing records and displays the total income from the Billing records. Your tests should test all the functions and constructors defined in your program. Your PDF file should clearly indicate what you are testing and the output.

Explanation / Answer

Below is the C++ code with comments

class FitnessMember
{
   string name;

   /* Constructor */
   FitnessMember()
   {
       name = null;
   }
   FitnessMember(string n)
   {
       name = n;
   }
   /* Accessor */
   string getName()
   {
       return name;
   }
   /* Mutator */
   void setName(string n)
   {
       name = n;
   }
   /* display */
   void display()
   {
       cout << "Name is :" << name;
   }
}

class Athlete : public FitnessMember
{
   string athleteId;

   /* Constructor */
   FitnessMember()
   {
       name = null;
       athleteId = null;
   }
   FitnessMember(string n, string id)
   {
       name = n;
       athleteId = id;
   }
   /* Accessor */
   string getName()
   {
       return name;
   }
   string getId()
   {
       return athleteId;
   }
   /* Mutator */
   string setName(string n, string id)
   {
       name = n;
       athleteId = id;
   }
   /* display */
   void display()
   {
       cout << "Name is :" << name;
       cout << "ID is :" << athleteId;
   }
}

class Trainer : public FitnessMember
{
   string speciality;
   double fee;

   /* Constructor */
   FitnessMember()
   {
       name = null;
       speciality = null;
       fee = 0;
   }
   FitnessMember(string n, string s, double f)
   {
       name = n;
       speciality = s;
       fee = f;
   }
   /* Accessor */
   string getName()
   {
       return name;
   }
   string getSpeciality()
   {  
       return speciality;
   }
   double getFee(double f)
   {
       return fee;
   }
   /* Mutator */
   void setName(string n)
   {
       name = n;
   }
   void setSpeciality(string s)
   {  
       speciality = s;
   }
   void setFee(double f)
   {
       fee = f;
   }
   /* display */
   void display()
   {
       cout << "Name is :" << name;
       cout << "Speciality is :" << speciality;
       cout << "Fee is :" << fee;
   }
}

class Billing : public Athlete, public Trainer
{
   double billAmount;
  
   /* Constructor */
   Billing()
   {
       billAmount = 0;
   }
   Billing(double n)
   {
       billAmount = n;
   }
   /* Accessor */
   string getBillAmount()
   {
       return billAmount;
   }
   /* Mutator */
   string setBillAmount(double n)
   {
       billAmount = n;
   }
   /* display */
   void display()
   {
       cout << "Bill Amount is :" << billAmount;
   }
  
   double Billing(Trainer t1, Athlete a1)
   {
       cout << "Billing for Athlete " << a1.name << " " << a1.athleteId;
       billAmount += t1.fee;
   }
}

int main()
{
Trainer t1 = new Trainer("One", "Weight", 1000);
Trainer t2 = new Trainer("Two", "Cardio", 1000);
  
Athlete a1 = new Athlete("AthleteOne", "abcd1234" );
Athlete a2 = new Athlete("AthleteTwo", "abcd4321" );
Athlete a3 = new Athlete("AthleteThree", "abcd143278" );
  
Billing b1, b2;
  
/* Billing b1 for Trainer t1 */
b1.Billing(t1,a1);
b1.Billing(t1,a2);
b1.Billing(t1,a3);
  
/* Billing b2 for Trainer t2 */
b2.Billing(t2,a1);
b2.Billing(t2,a2);
b2.Billing(t2,a3);
  
/* Printing the total bill amount */
cout << b1.display();
cout << b2.display();

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote