#include #include #include "Approval.cpp" #include "Client.cpp" #include "Exercise.cpp" using namespace std; class HealthClub { public: int clientCounter; int exerciseCounter; int approvalCounter; Client *clientArray[100]; Exercise *exerciseArray[100]; Approval *approvalArray[100]; HealthClub() { clientCounter=0; exerciseCounter=0; approvalCounter=0; } //displays the menu, reads in the users choice, and runs the proper method int menu() { string option="0"; while(option!="10") { option="0"; cout << "1) Add a new client to the program \n"; cout << "2) Display all clients in the program\n"; cout << "3) Add a new exercise to the program\n"; cout << "4) Display all exercises in the program\n"; cout << "5) Add an approval for an exercise for a client \n"; cout << "6) Display all approval records in program\n"; cout << "7) Add a performed record to the program\n"; cout << "8) Display all performed records in the program\n"; cout << "9) Determine if any clients performed more reps " << "than they were approved for\n"; cout << "10) Exit\n"; cout << "Enter a choice(1-10): "; cin >> option; if(option=="1") addClient(); else if(option=="2") printClients(); else if(option=="3") addExercise(); else if(option=="4") printExercises(); else if(option=="5") addApproval(); else if(option=="6") printApprovals(); else if(option=="7") addPerformance(); else if(option=="8") printPerformances(); else if(option=="9") printIfOverReps(); else if(option=="10") { break; } else { cout << "Your entry was invalid. Please enter your option.\n"; option="0"; } } } void addClient() { string inName=""; int incltID; cout << "Please enter Client's Name: "; getline(cin, inName); cout << "Please enter Client's ID Number: "; cin >> incltID; if(clientCounter==0) { clientArray[clientCounter]=new Client(inName, incltID); } else { for(int i=0; igetID()==incltID) { cout << "This client ID already exists!"; break; } } clientArray[clientCounter]=new Client(inName, incltID); } clientCounter++; } void printClients() { cout << "Name\tID#\n"; for(int i=0;iprintClient(); } } void addExercise() { string inExName=""; int inexID; cout << "Please enter Exercise Name: "; cin >> inExName; cout << "Please enter Exercise ID Number: "; cin >> inexID; if(exerciseCounter==0) { exerciseArray[exerciseCounter]=new Exercise(inExName, inexID); } else { for(int i=0; igetID()==inexID) { cout << "This exercise ID already exists!"; break; } } exerciseArray[exerciseCounter]=new Exercise(inExName, inexID); } exerciseCounter++; } void printExercises() { cout << "Name\tID#\n"; for(int i=0;iprintExercise(); } } void addApproval() { int inExID; int inCltID; string inApprDate; int inApprWeight; int inMaxReps; char validCltID='n'; char validExID='n'; cout << "Please enter Client's ID#: "; cin >> inCltID; cout << "Please enter Exercise ID Number: "; cin >> inExID; for(int i=0; igetID()==inCltID) { validCltID='y'; } } for(int i=0; igetID()==inExID) { validExID='y'; } } if(validCltID=='n') { cout << "The Client ID you entered does not exist. \n"; } if(validExID=='n') { cout << "The Exercise ID you entered does not exist. \n"; } if(validCltID=='y' && validExID=='y') { cout << "Please enter Approval Date: "; cin >> inApprDate; cout << "Please enter Approved Weight: "; cin >> inApprWeight; cout << "Please enter Max number of Reps: "; cin >> inMaxReps; approvalArray[approvalCounter]=new Approval(inCltID, inExID, inApprDate, inApprWeight, inMaxReps); approvalCounter++; } } void printApprovals() { cout << "Clt ID\tEx. ID#\tApproval Date\tAppr. Weight\tMax Reps\n"; for(int i=0;iprintApprovals(); } } void addPerformance() { int inExID; int inCltID; string inApprDate; string inDoneDate; int inDoneReps; char errorFlag='n'; cout << "Please enter Client's ID#: "; cin >> inCltID; cout << "Please enter Exercise ID Number: "; cin >> inExID; cout << "Please enter Approval Date: "; cin >> inApprDate; for(int i=0; igetCltID()==inCltID) { if(approvalArray[i]->getExID()==inExID) { if(approvalArray[i]->getApprovalDate()==inApprDate) { cout << "Please enter Done Date: "; cin >> inDoneDate; cout << "Please enter Number of Reps done: "; cin >> inDoneReps; approvalArray[i]->addPerformance(inDoneDate, inDoneReps); } else { errorFlag='y'; } } else { errorFlag='y'; } } else { errorFlag='y'; } } if(errorFlag=='y') { cout << "The information you entered doesn't match any approval records. \n"; } } void printPerformances() { cout << "Clt ID#\tEx. ID#\tApproval Date\tDone Date\t# Reps Done\n"; for(int i=0;iprintPerformances(); } } void printIfOverReps() { int tempID; int tempexID; string cltName; string exName; string apprDate; string doneDate; int numbReps; int maxReps; cout << "Name\tEx Name\tAppr. Date\tMax Reps\tDone Date\tReps Done\n"; for(int i=0;igetDoneReps()>approvalArray[i]->getMaxReps()) { tempID=approvalArray[i]->getCltID(); tempexID=approvalArray[i]->getExID(); apprDate=approvalArray[i]->getApprovalDate(); doneDate=approvalArray[i]->getDoneDate(); numbReps=approvalArray[i]->getDoneReps(); maxReps=approvalArray[i]->getMaxReps(); for(int i=0; igetID()==tempID) { cltName=clientArray[i]->getName(); } } for(int i=0; igetID()==tempexID) { exName=exerciseArray[i]->getName(); } } cout << cltName << "\t" << exName << "\t" << apprDate << "\t" << maxReps << "\t" << doneDate << "\t" << numbReps << endl; } } } }; //creates an instance of HealthClub and runs the menu int main() { HealthClub *myInstance=new HealthClub(); myInstance->menu(); delete myInstance; return 0; }