Question Details

(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");

}

 


Solution details:
STATUS
Answered
QUALITY
Approved
ANSWER RATING

This question was answered on: Dec 08, 2020

PRICE: $15

Solution~000652147485365.zip (25.37 KB)

Buy this answer for only: $15

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free solution (Deadline assured. Flexible pricing. TurnItIn Report provided)

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

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Dec 08, 2020

EXPERT

Tutor

ANSWER RATING

GET INSTANT HELP/h4>

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.

NEW ASSIGNMENT HELP?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.

Order Now