Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Prepare some classes to support statistical analyses of baseball players in a hy

ID: 3816771 • Letter: P

Question

Prepare some classes to support statistical analyses of baseball players in a hypothetical 'team' This could be used for baseball fantasy leagues or Rotisserie League Play. A Team is a collection of Players. It also includes a Manager. Maintain data members for the number of pitchers and the number of batters. An Employee generic (abstract) class to represent the common characteristics of the Team's employees, manager and players. Every Employee has a name and a salary and years in baseball. A Player is another generic (abstract) class to represent the common characteristics baseball players (in addition to those characteristics shared by all employees). Batters and Pitchers have different statistics, but a common statistic is the number of games played. A Pitcher is a class to collect pitching statistics. There are many, but to keep things simple for this assignment, we will choose only three: innings, earned runs, and strikeouts. A Batter is a class to collect hitting statistics. (Pitchers also bat, at least in the National League, but those statistics are usually ignored) Again, there are an enormous variety of statistics, but we will choose just three: at bats, hits, and home runs. A Manager represents the person who is the on-field manager. Besides the properties inherited from the Employee class, we will add two statistics: career wins, and career games. In summary, there are six classes: Team, Employee, Player, Batter, Pitcher, and Manager. Player and Manager are subclasses of Employee. Batter and Pitcher are subclasses of Player. Employee and Player are 'abstract' classes; each Employee is either a Manager or a Player, and each Player is either a Pitcher or a Batter,

Explanation / Answer

Source Code:

#include <iostream>
using namespace std;

   class Employee
   {
   public:
   string name;
   int salary,years;
   virtual void show()=0;
   };
  
   void Employee :: show()   
{
cout << name << salary << years;
}
  
class Player : public Employee
{
public:
int id;
string team_name;
virtual void show1()=0;
};
  
void Player :: show1()   
{
cout << id << team_name;
}
  
class Manager : public Employee
{
public:
int games,wins;
void get()
{
cout<< games << wins;
}
};
  
class Batter : public Player
{
public:
int bats,hits,runs;
void write()
{
cin>>bats>>hits>>runs;
}
};
  
class Pitcher : public Player
{
public:
int innings,earned_runs,strikeouts;
void write1()
{
cin>>innings>>earned_runs>>strikeouts;
}
};

int main()
{
    //code
    Employee e;
    e.show();
    Player p;
    p.show1();
    p.write();
return 0;
}