Question: This is c++ program i need help with and it needs to be compiled with GNU++ Compiler it has part A, b please do both

This is c++ program i need help with and it needs to be compiled with GNU++ Compiler

it has part A, b please do both

Part A

This is c++ program i need help with and it needs tobe compiled with GNU++ Compiler it has part A, b please doboth Part A Part B Baseball.cpp #include "Player.h" #include #include void displayArray(Playerteam[], int team_size); int sequeSearch(Player team[], int team_size,int number); int main() {

Part B

fstream fin("baseball.txt"); const int LIST_LENGTH = 20; int number = 0, hits,

Baseball.cpp

#include "Player.h"

#include

#include

void displayArray(Player team[], int team_size);

int sequeSearch(Player team[], int team_size,int number);

int main()

{

fstream fin("baseball.txt");

const int LIST_LENGTH = 20;

int number = 0, hits, walks, outs,players,index,teamSize = 0;

cout

Player team[LIST_LENGTH];

fin >> number >> hits >> walks >> outs;

while (!fin.eof())

{

int index=sequeSearch(team, teamSize, number);

if(index == -1)

{

team[teamSize].setNumber(number);

team[teamSize].setHits(hits);

team[teamSize].setWalks(walks);

team[teamSize].setOuts(outs);

teamSize++;

}

else

{

team[index].setHits(hits);

team[index].setWalks(walks);

team[index].setOuts(outs);

}

fin >> number >> hits >> walks >> outs;

}

displayArray(team,teamSize);

fin.close();

}

void displayArray(Player team[], int team_size)

{

cout

for (int i=0; i

{

cout

}

}

int sequeSearch(Player team[], int team_size,int number)

{

for (int i=0; i

{

if(team[i].getNumber()==number)

return i;

}

return -1;

}

Baseball.txt

baseball.txt 1 2 2 2 19 0 5 1 2 0 0 6 18 4 2 0 4 1 2 3 12 2 2 2 7 0 0 3 8 1 4 1 10 2 2 2 3 2 1 3 11 6 0 0 2 0 5 1 19 0 0 6 17 4 2 0 9 3 2 1 4 2 1 3 3 1 2 3 7 0 0 3

Player.cpp

#include "Player.h" #include #include using namespace std;

Player::Player() { Number = Hits = Walks = Outs = 0; }

int Player::getNumber() const { return Number; }

int Player::getHits() const { return Hits; }

int Player::getWalks() const { return Walks; }

int Player::getOuts() const { return Outs; }

void Player::setNumber(int n) { Number = n; }

void Player::setHits(int h) { Hits = h; }

void Player::setWalks(int w) { Walks = w; }

void Player::setOuts(int o) { Outs = o; }

// support for assignments const Player& Player::operator=(const Player & p) { // bypass self assignment if (this != &p) { Number = p.Number; Hits = p.Hits; Walks = p.Walks; Outs = p.Outs; } return *this; }

// support for output to the monitor ostream& operator

Player.h

Player.h:

#ifndef PLAYER #define PLAYER #include using namespace std; class Player { public: Player(); int getNumber() const; int getHits() const; int getWalks() const; int getOuts() const; void setNumber(int); void setHits(int); void setWalks(int); void setOuts(int); const Player& operator=(const Player &); friend ostream& operator

Modify the program that you wrote for the last exercise in a file named Basebal12.cpp that uses the Player class stored within an array. The program should read data from the file baseball.txt for input. The Player class should once again be stored in files named Player.h and Player.cpp, however Basebal1.cpp is the only file that you need to modify for this assignment. Once all of the input data from the file is stored in the array, code and invoke a function named selectionSort() that sorts the array of Player objects in the ascending order of the Player Number field using the Selection Sort algorithm. Display the Number, Hits, Walks and Outs data attributes to the monitor for each array element both before and after sorting The main() function for this program is once again in the file Baseball2.cpp Your solution from the last assignment connects to the sequential input file baseball.txt, inputs all of the int values in the file, and updates the Player's statistics for display. We'll need to remember to disconnect from the input file when we're done. Once again, all output should be displayed to the monitor. 1. process to connect the input file fin to the program and set teamSize to0 2. output an informational message to the screen about the program 3. process declare an array of length 20 of type Player named team[ ] 4. input the Number, Hits, Walks and Runs of a Player 5. process while not-end-of-file fin a. process determine if the Number is stored in the first teamSize elements b. process if the Number is not stored in the array i. process Number of teamsize is argument to setNumber() li. process Hits of teamSize is argument to setHits() ii. process Walks of teamSize is argument to setWalks() iv. process Outs of teamSize is argument to setouts() v. process increase teamSize by 1 C. process else if team[ index] contains Number i. process Hits +getHits () of index is argument to setHits() li. process Walks + getWalks() of index is argument to setWalks () i. process Outs getouts () of index is argument to setouts () d. input the Number, Hits, Walks and Runs of a Player

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!