示例#1
0
void saveScoresToFile(std::vector<Score> list)
{
    std::ofstream outfile;
    outfile.open("highscores.txt");

    for ( unsigned int i = 0; i < list.size(); i++ )
    {
        Score temp = list.at(i);
        outfile<< temp.Getname() << ":" << temp.Getscore() << std::endl;
    }

    outfile.close();
}
示例#2
0
std::string convertScoresToString(std::vector<Score> list)
{

    std::stringstream out;

    out<< "High Scores:\n";

    if ( list.size() == 0 )
    {
        out<< "No scores recorded";
        return out.str();
    }

    for ( unsigned int i = 0; i < list.size(); i++ )
    {
        Score temp = list.at(i);

        out<< temp.Getname() << " - " << temp.Getscore() << std::endl;
    }

    return out.str();
}