Question

C++ Assignment: Create a class called FitnessMember that has only one variable, called name. The FitnessMember...

C++ Assignment:

Create a class called FitnessMember that has only one variable, called name. The FitnessMember 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), ID number of type String and integer number of training days.

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 training session fee per day (use the type double).

Billing class has Athlete and Trainer objects as private data members. A Billing record 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 trainer 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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include <string>
#include <vector>
#include <iostream>

class FitnessMember
{
public:
std::wstring name;

virtual void setName(const std::wstring &name)
{
this->name = name;
}

virtual std::wstring getName()
{
return name;
}
};

class Athelete : public FitnessMember
{
public:
std::wstring ID;

Athelete(const std::wstring &name)
{
FitnessMember::name = name;
}

virtual void setID(const std::wstring &ID)
{
this->ID = ID;
}

virtual std::wstring getID()
{
return ID;
}
};

class Trainer : public FitnessMember
{
public:
std::wstring speciality;

Trainer(const std::wstring &name)
{
FitnessMember::name = name;
}

virtual void setSpeciality(const std::wstring &sp)
{
speciality = sp;
}

virtual std::wstring getSpeciality()
{
return speciality;
}
};

class Billing
{
public:
int amt = 0;

virtual void generateBill(Athelete *a, Trainer *t)
{
if (t->speciality.equalsIgnoreCase(L"weight") || t->speciality.equalsIgnoreCase(L"cardio"))
{
amt = 300;
std::wcout << std::wstring(L"BILL FOR : ") << a->name << std::wstring(L" IS : $") << amt << std::endl;
}
else
{
amt = 350;
std::wcout << std::wstring(L"BILL FOR : ") << a->name << std::wstring(L" IS : $") << amt << std::endl;
}
}
};

class AtheleteTest
{
static void main(std::vector<std::wstring> &args)
{
Athelete *a1 = new Athelete(L"XXX");
Athelete *a2 = new Athelete(L"YYY");

a1->setID(L"A123");
a2->setID(L"A456");

Trainer *t1 = new Trainer(L"AAA");
Trainer *t2 = new Trainer(L"BBB");

t1->setSpeciality(L"cardio");
t2->setSpeciality(L"nutrition");

Billing *b1 = new Billing();
Billing *b2 = new Billing();

b1->generateBill(a1, t1);
b2->generateBill(a2, t2);

std::wcout << std::wstring(L"TOTAL BILL IS : $") << (b1->amt << b2->amt) << std::endl;
}
};

Add a comment
Know the answer?
Add Answer to:
C++ Assignment: Create a class called FitnessMember that has only one variable, called name. The FitnessMember...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Overload a relational operator for the Job class: Assume that this operator is not overloaded for...

    Overload a relational operator for the Job class: Assume that this operator is not overloaded for the Salary class. a) Write how the function will be declared in your code. b) Write an external function definition (not inside the class). solve it in C++10 to solve this you nedd question number 1. Create a composition between the classes Job and Salary. Class Salary a. data member:    1. money b. constructors:    1. default constructor    2. user defined constructor with a parameter...

  • C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to...

    C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to the project. Copy and paste the code is listed below: Design a class named Employee. The class should keep the following information in member variables: Employee name Employee number Hire date // Specification file for the Employee class #ifndef EMPLOYEE_H #define EMPLOYEE_H #include <string> using namespace std; class Employee { private:        // Declare the Employee name string variable here. // Declare the Employee...

  • solve it in c++10 Create a composition between the classes Job and Salary. Class Salary a....

    solve it in c++10 Create a composition between the classes Job and Salary. Class Salary a. data member:    1. money b. constructors:    1. default constructor    2. user defined constructor with a parameter to set money c. standard accessor and mutator functions Class Job a. data members:    title (name of the job)    salary (object of type Salary) b. constructors:    1. default constructor    2. user defined constructor to set title and salary    3. implement constructor delegation c. standard accessor and mutator function...

  • Write a C++ program Write a class named Employee that has the following member variables: name...

    Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...

  • Code should be in C# Create a class called SavingsAccount.  Use a static variable called annualInterestRate to...

    Code should be in C# Create a class called SavingsAccount.  Use a static variable called annualInterestRate to store the annual interest rate for all account holders.  Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance.  Provide static method setAnnualInterestRate to set the annualInterestRate to a new value....

  • Java: Create a class called Vehicle with the following features: a. It has three private data...

    Java: Create a class called Vehicle with the following features: a. It has three private data members (instance variables): one is the manufacturer’s name (String manufacturer), the second is the number of cylinders in the engine (int cylinder), and the third is the owner (Person owner). The class Person is described above. b. It has three constructors, a no-argument constructor, a constructor with three parameters, and a copy constructor. The no-argument constructor will set the manufacturer to “None”, cylinder to...

  • C++ ONLY This is your first ever program using object oriented methodology. In this assignment you...

    C++ ONLY This is your first ever program using object oriented methodology. In this assignment you will need to instantiate (create) object(s) and invoke their member functions to perform different tasks. The program is to keep track of customer orders and to create reports as needed. At minimum you will need several objects to be instantiated throughout the program such as: An OrderProcessor object Order objects (stored in an array) Let’s get to class design now. Class Design class Order:...

  • Write a class named PhoneBookEntry that has fields for a person's name and phone number.The class...

    Write a class named PhoneBookEntry that has fields for a person's name and phone number.The class should have a constructor and appropriate accessor and mutator methods. Thenwrite a program that creates at least five PhoneBookEntry objects and stores them in anArrayLitt. Use a loop to display the contents of each object in the ArrayList.

  • Using C++ create a class called person. A person can have a name, address, age. For...

    Using C++ create a class called person. A person can have a name, address, age. For this class create a default constructor and parameterized constructor. Show the main as int main() { } ----------------------------------------------------- Show how you will define the class and call it in the main. Only create two instances/objects in main using the two created constructors.

  • in C++: Create a class named Student that has three member variables: name - string that...

    in C++: Create a class named Student that has three member variables: name - string that stores the name of the student numClasses - integer that tracks how many courses the student is currently enrolled in, this number must be between 1 and 100. classList - an array of strings of size 100 used to store the names of the classes that the student is enrolled in Write the appropriate constructor(s), mutator and accessor functions for the class along with...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT