//this is client file //file name is main.cpp #include #include #include //This library is needed for using input/output of files #include "Player.h" using namespace std; int main(){ ifstream inData; //declare input file stream ofstream outData; //declare output file stream inData.open("players.txt"); //open input file //Check for error in opening file if (inData.fail()) { cerr << "Error opening file" << endl; exit(1); } Player players[500]; string fname; string lname; string team; string position; int salary; float valuePoints; float projPoints; float pointCost; int i = 0; string header; getline(inData, header); int teamsalary = 50000; int countPG = 0; int countSG = 0; int countSF = 0; int countPF = 0; int countC = 0; int countG = 0; int countF = 0; int countU = 0; bool isPG = false; bool isSG = false; bool isSF = false; bool isPF = false; bool isC = false; bool isG = false; bool isF = false; bool isU = false; inData >> fname; inData >> lname; inData >> team; inData >> position; inData >> salary; inData >> valuePoints; inData >> projPoints; inData >> pointCost; while (inData.good()){ Player player1(fname + " " + lname, team, position, salary, valuePoints, projPoints, pointCost); players[i] = player1; // float maxvalue = player1.getvaluePoints(); //get point guard if (player1.isPG(position) && !isPG && teamsalary > 0){ teamsalary = teamsalary - player1.getSalary(); cout << player1.getName() << " " << player1.getPosition() << " " << player1.getSalary() << " " << player1.getvaluePoints() << endl; countPG++; isPG = true; } //get shooting guard if (player1.isSG(position) && !isSG && teamsalary > 0){ teamsalary = teamsalary - player1.getSalary(); cout << player1.getName() << " " << player1.getPosition() << " " << player1.getSalary() << " " << player1.getvaluePoints() << endl; countSG++; isSG = true; } //get small forward if (player1.isSF(position) && !isSF && teamsalary > 0){ teamsalary = teamsalary - player1.getSalary(); cout << player1.getName() << " " << player1.getPosition() << " " << player1.getSalary() << " " << player1.getvaluePoints() << endl; countSF++; isSF = true; } //get power forward if (player1.isPF(position) && !isPF && teamsalary > 0){ teamsalary = teamsalary - player1.getSalary(); cout << player1.getName() << " " << player1.getPosition() << " " << player1.getSalary() << " " << player1.getvaluePoints() << endl; countPF++; isPF = true; } //get center if (player1.isC(position) && !isC && teamsalary > 0){ teamsalary = teamsalary - player1.getSalary(); cout << player1.getName() << " " << player1.getPosition() << " " << player1.getSalary() << " " << player1.getvaluePoints() << endl; countC++; isC = true; } //get point guard or shooting guard if (player1.isG(position) && !isG && teamsalary > 0){ teamsalary = teamsalary - player1.getSalary(); cout << player1.getName() << " " << player1.getPosition() << " " << player1.getSalary() << " " << player1.getvaluePoints() << endl; countG++; isG = true; isPG = true; } //get small forward or power forward /*if (player1.isF(position) && !isF && teamsalary > 0){ teamsalary = teamsalary - player1.getSalary(); cout << player1.getName() << " " << player1.getPosition() << " " << player1.getSalary() << " " << player1.getvaluePoints() << endl; countF++; isF = true; }*/ //get player from any position /*if (player1.isU(position) && !isU && teamsalary > 0){ teamsalary = teamsalary - player1.getSalary(); cout << player1.getName() << " " << player1.getPosition() << " " << player1.getSalary() << " " << player1.getvaluePoints() << endl; countU++; isU = true; }*/ inData >> fname; inData >> lname; inData >> team; inData >> position; inData >> salary; inData >> valuePoints; inData >> projPoints; inData >> pointCost; i++; } cout << teamsalary << endl; return 0; }