Read Function c++ HELPP!!

I'm really having trouble finding a code to compile my program but here it goes.
All i need is to create a "read" function to read all the data for a Player Object.

So Far i made a display function to display all the data for the "Player" object, but i don't know how to make a read function.

Here is my program:

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include "player.h"
#include "weapon.h"
#include "utilities.h"

using namespace std;

const int MIN = 1;
const int MAX = 100;

void displayPlayer(const vector<Player>& ePlayer);
void readPlayer(const vector<Player>&ePlayer, string pName, int ptype, int plevel, int pstrength, int wtype, int wdurability, int wlevRequired);

// main function ***********************************************************

int main()
{
vector <Player> gamePlayers;
string playerName;
int playerType, playerLevel, playerStregth, weaponType, weaponDurability, weaponlvlRequired;

readPlayer(gamePlayers, playerType, playerLevel, playerStregth, weaponType, weaponDurability, weaponlvlRequired);

displayPlayer(gamePlayers);

// End of program statements
cout << "Please press enter once or twice to continue...";
cin.ignore().get(); // hold console window open
return EXIT_SUCCESS; // successful termination

}

void readPlayer(vector<Player> ePlayer,string pName, int ptype, int plevel, int pstrength, int wtype, int wdurability, int wlevRequired)
{
for (int i = 0; i < 3; ++i)
{
cout << "Enter player name: ";
cin >> pName;
cout << "Enter player type (1, 2, 3, 4): ";
ptype = readValidInteger(1, 4);
cout << "Enter player level (>=1 && <= 100):";
plevel = readValidInteger(1, 100);
cout << "Enter player strength (>= 25):";
pstrength = readValidInteger(25, 200);
cout << "Enter weapon type (1, 2, 3, 4): ";
wtype = readValidInteger(1, 4);
cout << "Enter weapon durability (>= 25):";
wdurability = readValidInteger(25, 200);
cout << "Enter weapon level required (>=1 && <=100): ";
wlevRequired = readValidInteger(1, 100);

ePlayer.push_back(Player(pName, ptype, plevel, pstrength,
wtype, wdurability, wlevRequired));

cout << endl;
}
}


void displayPlayer(const vector<Player>& ePlayer)
{
for (int i = 0; i < ePlayer.size(); i++)
{
cout << left;
cout << setw(20) << "Player Name: " << setw(20)
<< ePlayer[i].getPlayerName() << endl;
cout << setw(20) << "Player Type: " << setw(10)
<< ePlayer[i].getType() << endl;
cout << setw(20) << "Player Level: " << setw(10)
<< ePlayer[i].getLevel() << endl;
cout << setw(20) << "Player Strength: " << setw(10)
<< ePlayer[i].getStrength() << endl;
cout << setw(20) << "Weapon Type: " << setw(10)
<< ePlayer[i].getWeaponType() << endl;
cout << setw(20) << "Weapon Durabiliry: " << setw(10)
<< ePlayer[i].getWeaponDurability() << endl;
cout << setw(20) << "Weapon Level Required: " << setw(10)
<< ePlayer[i].getWeaponLevelRequired() << endl << endl;
}
}
Topic archived. No new replies allowed.