Question: IN C++ This is my code and the picture is the provided input data/output data, can someone turn this into a linked list alphabetical order

IN C++ This is my code and the picture is the provided input data/output data, can someone turn this into a linked list alphabetical order and put a function to remove by entering the person's name?

PlayerList.cpp

#include "PlayerList.h"

using namespace std;

//***************************************************************************//

/* FILE: PlayerList.cpp

Class: PlayerList

This is the implementation file for the methods defined in class

PlayerList. Please see PlayerList.h for a description of the interface

*/

//---------------------------------------------------------------------------//

// Constructor: Default

// This constructor initializes a PlayerList to a pristine state.

// The index reflects the fact that the internal array is empty.

//---------------------------------------------------------------------------//

PlayerList::PlayerList() {

head = nullptr;

clear();

}

//---------------------------------------------------------------------------//

// add(P) : takes the input player and copies it into the list

// If the list is full, this operation will fail.

//---------------------------------------------------------------------------//

bool PlayerList::add(const BaseballPlayer &P) {

bool success = false;

if (!isFull()) {

mItems[mPlayerCount] = P; // copy it in

mPlayerCount++;

success = true;

}

return success;

}

//---------------------------------------------------------------------------//

// resetIteration() - gets this list ready to begin an iteration through

// its data

//---------------------------------------------------------------------------//

void PlayerList::resetIteration() {

mCurrentIndex = 0; // starts at front of array for data retrieval

}

//---------------------------------------------------------------------------//

// getNext()

// Returns a copy of next item in the iteration. If the list is at the end,

// do not move the index over anymore

// Returns one baseball player object

//---------------------------------------------------------------------------//

BaseballPlayer PlayerList::getNext( ) {

BaseballPlayer temp;

temp = mItems[mCurrentIndex];

if (mCurrentIndex

mCurrentIndex++; // move over one if there are more items in the list

return temp;

}

//---------------------------------------------------------------------------//

// hasNext()

// Returns true if there are more items in the list to be iterated through

//---------------------------------------------------------------------------//

bool PlayerList::hasNext()

{

return (mCurrentIndex

}

//---------------------------------------------------------------------------//

// calculate()

// Instructs the list to perform internal, list wide computation(s)

// Computes the overall team average

//---------------------------------------------------------------------------//

void PlayerList::calculate() {

double sumAverages = 0.0;

int i;

for (i = 0; i

sumAverages = sumAverages + mItems[i].getBattingAverage();

}

if (mPlayerCount > 0)

mAverage = sumAverages / mPlayerCount;

else

mAverage = 0.0; // to be safe, don't divide by 0!

}

//---------------------------------------------------------------------------//

//---------------------------------------------------------------------------//

double PlayerList::getAverage() {

return mAverage;

}

//---------------------------------------------------------------------------//

// clear() - sets the list to an empty state

//---------------------------------------------------------------------------//

void PlayerList::clear() {

mPlayerCount = 0;

mCurrentIndex = 0; // set current index for iteration

mAverage = 0.0;

}

//---------------------------------------------------------------------------//

// getCount() - returns the count of students currently in this list

//---------------------------------------------------------------------------//

int PlayerList::getCount() {

return mPlayerCount;

}

//---------------------------------------------------------------------------//

// isFull() - returns true if the list is at capacity, false otherwise

//---------------------------------------------------------------------------//

bool PlayerList::isFull() {

return (mPlayerCount >= MAXSIZE);

}

BaseballPlayer.cpp

#include "BaseballPlayer.h"

//-----------------------------------------------------------------------------------------------//

// Default Constructor

// Sets numberic values to zeros, and other values to either empty strings or default values

//-----------------------------------------------------------------------------------------------//

BaseballPlayer::BaseballPlayer() {

mFirstName = "unknown";

mLastName = "unknown";

for (int i = 0; i

mHitting[i] = 0;

}

//-----------------------------------------------------------------------------------------------//

// read(input)

// VERSION 2: reads in plate apperances before the hits data, and the walks and HBP

//

// This method reads the baseball player's data from a single line on an input stream.

// Some special restrictions - the player's first name and last name can each only consist of

// a single word (no embedded spaces), other wise the input will be read in incorrectly.

// There must also be all 5 statistics data values on the line.

// The order of input is firstname lastname appearances atbats singles doubles triples homeruns walks hbp

//

// Parameters:

// input : a variable representing the input stream to read data from

//-----------------------------------------------------------------------------------------------//

void BaseballPlayer::read(istream &input) {

input >> mFirstName >> mLastName;

input >> mHitting[APPEARANCES]; // i am storing the first value at the end of my data array

for (int i = ATBATS; i

input >> mHitting[i]; // read in each stat from input stream

}

//-----------------------------------------------------------------------------------------------//

// computeStats

// This function currently computes the player's batting average based on the hitting data.

// Later revisions will compute additional player statistics.

//-----------------------------------------------------------------------------------------------//

void BaseballPlayer::computeStats() {

mBattingAverage = 0.0;

mSluggingPercentage = 0.0;

for (int i = SINGLES; i

mBattingAverage = mBattingAverage + mHitting[i];

mSluggingPercentage = mSluggingPercentage + (i * mHitting[i]);

}

if (mHitting[ATBATS] > 0) {

mBattingAverage = mBattingAverage / mHitting[ATBATS];

mSluggingPercentage = mSluggingPercentage / mHitting[ATBATS];

}

else {

mBattingAverage = 0.0; // if there was a 0 in the at bats, we can't divide by it

mSluggingPercentage = 0.0;

}

// compute on base percentage too

mOnBasePercentage = 0.0;

for (int i = SINGLES; i

mOnBasePercentage = mOnBasePercentage + mHitting[i];

}

if (mHitting[APPEARANCES] > 0)

mOnBasePercentage = mOnBasePercentage / mHitting[APPEARANCES];

else

mOnBasePercentage = 0.0;

}

//-----------------------------------------------------------------------------------------------//

// getFullName()

// This get method is used to get the player's full name built as a single string from the

// names stored in the class.

//-----------------------------------------------------------------------------------------------//

string BaseballPlayer::getFullName() {

return mFirstName + " " + mLastName;

}

//-----------------------------------------------------------------------------------------------//

// getFirstName()

// This get method is used to get the player's first name

//-----------------------------------------------------------------------------------------------//

string BaseballPlayer::getFirstName() {

return mFirstName;

}

//-----------------------------------------------------------------------------------------------//

// getLastName()

// This get method is used to get the player's last name

//-----------------------------------------------------------------------------------------------//

string BaseballPlayer::getLastName() {

return mLastName;

}

//-----------------------------------------------------------------------------------------------//

// getBattingAverage()

// Used to retrieve the batting average for this player after it has been computed.

//-----------------------------------------------------------------------------------------------//

double BaseballPlayer::getBattingAverage() {

return mBattingAverage;

}

//-----------------------------------------------------------------------------------------------//

// getSluggingPercentage()

// Used to retrieve the slugging average for this player after it has been computed.

//-----------------------------------------------------------------------------------------------//

double BaseballPlayer::getSluggingPercentage() {

return mSluggingPercentage;

}

//-----------------------------------------------------------------------------------------------//

// getOnBasePercentage()

// Used to retrieve the on base average for this player after it has been computed.

//-----------------------------------------------------------------------------------------------//

double BaseballPlayer::getOnBasePercentage() {

return mOnBasePercentage;

Program3.cpp

using namespace std;

#include

#include

#include

#include "PlayerList.h"

//-----------------------------------------------------------------------------------------------//

// Main program

// Uses a single variable to store a player temporarily until it is added to the list.

// The loop reuses the variable over and over until all lines of the input file have been

// retrieved.

//-----------------------------------------------------------------------------------------------//

int main(void) {

string inFileName, outFileName; // names of the input and output data files supplied by the user

ifstream inputFile; // input file handle

ofstream outputFile; // output file handle

BaseballPlayer p1; // a temporary object = the current player being read or printed

PlayerList myTeamRoster;// the list storage

char option;

string fname, lname;

cout

cout

cout

cout

cout

cout

cout > inFileName;

cout > outFileName;

// opening data files

inputFile.open(inFileName.c_str());

if (inputFile.fail()) {

cout

cout

}

outputFile.open(outFileName.c_str());

if (outputFile.fail()) {

cout

cout

}

cout

int count = 0; // tbd later

while (!inputFile.eof() && !myTeamRoster.isFull()) {

p1.read(inputFile);

p1.computeStats();

myTeamRoster.add(p1); // add this player to the list

}

myTeamRoster.calculate(); // perform computations on roster

outputFile

outputFile

outputFile

outputFile

outputFile

myTeamRoster.resetIteration(); // get ready to visit each student

while (myTeamRoster.hasNext()) {

p1 = myTeamRoster.getNext();

outputFile

outputFile

outputFile

outputFile

outputFile

}

cout

cout

cin >> option;

if (option == 'y' || option == 'Y') {

string fname, lname;

cout

cin >> fname >> lname;

}

inputFile.close();

outputFile.close();

cout

cout

return 0;

}

IN C++ This is my code and the picture is the providedinput data/output data, can someone turn this into a linked list alphabetical

C IN C++Can Soneone Show Me x Program 3 xProgramming Assignment 3 (x + C file///C:/Usersmro00/Downl 0(1).pclf Programming Assignment 3 (1).pdf 213 Sample Exccution Welcome to the player atatistics calculator teat progra. I ar going to read players trom an input data tile. You will tell me the names ot your input and output files. I wi11 store all of the players in a list, compute each player' averages and then write the resulting team report to your output tile Enter the name of your input file playerinput.txt Enter the name of your output file: report.txt Reading Players from: playerinput.txt The team data has been written to your output file: report.txt Nould you like to remove any players from your team? Y Please enter the Pirst and Last Name of the Player Ty Cobb Ty Cobb Removed SuccessEully Nould you like to remove any players from your team? Y Please ent r the First and Last Name f the Player: John Smith John Smith was not found in your team Nould you like to remove any players from your team? N Testing Complete. The new version of your team has been added to the report file End of Program 3 Press any key to continue. . Page 2 of Programming Assi... .f Programming Ass...f Show all X 1-02 Mw Fa Programz (1)zip O Type here to search 1002 AM 1015/2018 2 C IN C++Can Soneone Show Me x Program 3 xProgramming Assignment 3 (x + C file///C:/Usersmro00/Downl 0(1).pclf Programming Assignment 3 (1).pdf 213 Sample Exccution Welcome to the player atatistics calculator teat progra. I ar going to read players trom an input data tile. You will tell me the names ot your input and output files. I wi11 store all of the players in a list, compute each player' averages and then write the resulting team report to your output tile Enter the name of your input file playerinput.txt Enter the name of your output file: report.txt Reading Players from: playerinput.txt The team data has been written to your output file: report.txt Nould you like to remove any players from your team? Y Please enter the Pirst and Last Name of the Player Ty Cobb Ty Cobb Removed SuccessEully Nould you like to remove any players from your team? Y Please ent r the First and Last Name f the Player: John Smith John Smith was not found in your team Nould you like to remove any players from your team? N Testing Complete. The new version of your team has been added to the report file End of Program 3 Press any key to continue. . Page 2 of Programming Assi... .f Programming Ass...f Show all X 1-02 Mw Fa Programz (1)zip O Type here to search 1002 AM 1015/2018 2

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!