Commit ea5b5f7e authored by Allen B. Doelue's avatar Allen B. Doelue

Opens the PlayersLists.txt file and uses the data to create player objects

parent 6ff87add
#include <iostream>
using namespace std;
#include "Player.h"
#include <fstream>
#include <sstream>
int main()
{
//open file and read lines
ifstream myfile("PlayersList.txt");
if(myfile.is_open())
{
while(!myfile.eof()) //while not at end of file
{
string username;
string rankStr;
unsigned rank;
//store player data into strings
getline(myfile, username, '-');
getline(myfile, rankStr, '\n');
//convert rank string to int
stringstream conversion(rankStr);
conversion >> rank;
//create player object
Player p(username, rank);
p.displayName();
cout<<p.getRank()<<endl;
//enqueue and repeat with next player
}
}
else cout<<"file cannot open";
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment