- #1
WarGhSt
- 15
- 0
Working on a project here - I've got the classes [MINUS Billing] defined and, as far as I know, meet the requirements for the constructors, accessors, and mutator functions.
My problem lies with the Billing class. It asks me to create an athlete and trainer object inside the billing class but either it was a topic that was supposed to be so easy that it was assumed I'd know it immediately or it wasn't covered. I've spent the last hour or two looking around google and through my textbook but so far I've come up with very little. On top of that, I'm not sure I understand the need for Billing to be its own class to begin with.
View attachment 5573My code:
My problem lies with the Billing class. It asks me to create an athlete and trainer object inside the billing class but either it was a topic that was supposed to be so easy that it was assumed I'd know it immediately or it wasn't covered. I've spent the last hour or two looking around google and through my textbook but so far I've come up with very little. On top of that, I'm not sure I understand the need for Billing to be its own class to begin with.
View attachment 5573My code:
Code:
#include <iostream>
#include <string>
using namespace std;
class FitnessMember {
private:
string name;
public:
FitnessMember(){
name = "";
}
FitnessMember(string fitName){
name = fitName;
}
string getName() const {
return name;
}
void setName(string fitName){
name = fitName;
}
};
class Athlete: public FitnessMember {
private:
int idNum;
public:
Athlete(string name, int idNumIs) : FitnessMember(name)
{
idNum = idNumIs;
}
int getidNum() {
return idNum;
}
};
class Trainer: public FitnessMember {
private:
string specialty;
double cost;
public:
Trainer(string name, string specialtyIs, double costIs) : FitnessMember(name)
{
specialty = specialtyIs;
cost = costIs;
}
string getSpecialty(){
return specialty;
}
double getCost(){
return cost;
}
};
int main()
{
Athlete aAthlete("Jerry", 1348);
Athlete bAthlete("Crabbe", 10041);
Trainer aTrainer("Sally", "Squats", 75.44);
Trainer bTrainer("Malfoy", "Cardio", 90.12);
cout << "Athlete name: " << aAthlete.getName() << endl;
cout << "Athlete idnum: " << aAthlete.getidNum() << endl;
cout << "Athlete name: " << bAthlete.getName() << endl;
cout << "Athlete idnum: " << bAthlete.getidNum() << endl;
cout << "Trainer name: " << aTrainer.getName() << endl;
cout << "Trainer specialty: " << aTrainer.getSpecialty() << endl;
cout << "Trainer cost: $" << aTrainer.getCost() << endl;
cout << "Trainer name: " << bTrainer.getName() << endl;
cout << "Trainer specialty: " << bTrainer.getSpecialty() << endl;
cout << "Trainer cost: $" << bTrainer.getCost() << endl;
return 0;
}