(Solution Document) How would I be able to split this program in order to use header files. #include <iostream> #include <string> using namespace std; class...


How would I be able to split this program in order to use header files.


#include

#include

using namespace std;


class Athlete

{

   string name;

   double salary;


public:

   Athlete(string n, double s)

   {

      name = n;

      salary = s;

   }


   virtual double getSalary() = 0;


   string getName()

   {

      return name;

   }


   void setName(string s)

   {

      name = s;

   }


   void setSalary(double s)

   {

      salary = s;

   }


   double salaryPerGame()

   {

      return salary;

   }

};


class BaseBallPlayer: public Athlete

{

public:

   BaseBallPlayer(string n, double s):Athlete(n, s){}

   double getSalary()

   {

      return 162 * Athlete::salaryPerGame();

   }

};


class BasketBallPlayer: public Athlete

{

public:

   BasketBallPlayer(string n, double s):Athlete(n, s) {}

   double getSalary()

   {

      return 82 * Athlete::salaryPerGame();

   }

};


class FootBallPlayer: public Athlete

{

public:

   FootBallPlayer(string n, double s):Athlete(n, s) {}

   double getSalary()

   {

      return 16 * Athlete::salaryPerGame();

   }

};


class SoccerPlayer: public Athlete

{

public:

   SoccerPlayer(string n, double s):Athlete(n, s) {}

   double getSalary()

   {

      return 38 * Athlete::salaryPerGame();

   }

};


int main()

{

   Athlete** athletes = new Athlete*[4];

   athletes[0] = new BaseBallPlayer("MyBaseBall Player1", 200);

   athletes[1] = new BasketBallPlayer("MyBasketBall Player2", 130);

   athletes[2] = new FootBallPlayer("MyFootBall Player3", 340);

   athletes[3] = new SoccerPlayer("MySoccer Player4", 140);

 

   for(int i=0; i<4; i++)

   {

      cout << athletes[i]->getName() << ", Salary: " << athletes[i]->getSalary() << endl;

   }


   system("pause");

}

 







About this question:

Pay using PayPal (No PayPal account Required) or your credit card. All your purchases are securely protected by .
SiteLock