Skip to content
Snippets Groups Projects
Commit f96cc33a authored by Loke Nesse Svelland's avatar Loke Nesse Svelland
Browse files

tried to make read and write to files work

parent b8418e0f
No related branches found
No related tags found
No related merge requests found
......@@ -86,12 +86,17 @@ void Player::calculateScore()
*/
void Player::writeToFilePlayer(ofstream &out)
{
out << setw(80) << firstName
<< setw(80) << lastName
<< setw(80) << rating
<< setw(80) << playerID
<< setw(80) << club
<< "\n";
out << firstName << '\n'
<< lastName << '\n'
<< rating << '\n'
<< playerID << '\n'
<< club << '\n'
<< white << '\n';
for(int i = 0; i < results.size(); i++)
out << results[i];
out << '\n';
for(int i = 0; i < playedAgainst.size(); i++)
out << playedAgainst[i];
}
/**
......@@ -101,13 +106,22 @@ void Player::writeToFilePlayer(ofstream &out)
*/
void Player::readFromFilePlayer(ifstream &in)
{
int inn;
getline(in, firstName);
getline(in, lastName);
in >> rating;
in.ignore();
in >> playerID;
in.ignore();
in >> rating; in.ignore();
in >> playerID; in.ignore();
getline(in, club);
in >> white; in.ignore();
while(!'\n') {
in >> inn;
results.push_back(inn);
}
while(!in.eof()) {
in >> inn;
playedAgainst.push_back(inn);
}
}
int Player::currentRank(int id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment