Erros with my methods and constructors

the purpose of this program is to take the players information and change it using structures but I am stuck and dont know how to fix the problems with it


#include <iostream>
#include <iomanip>

using namespace std;

//*************** Place your class description after this line ***************

class Player
{
public:
Player();
Player( const char [], int, int, int );

void printPlayer();

void setName(const char [] );
void setGoals( int );
void setAssists( int );
void setRating( int );

int getGoals();
int getAssists();
int getRating();

private:
char name[50];
int goals;
int assists;
int rating;
};

//****************************************************************************

int main()
{
//Test 1 -- default constructor
Player player1( "Kushtrim Berisha/Greg Johnsen", 1, 1, 1);
Player player2();
Player player3("Johanthan Toews", 10, 9, 6);
Player player4("Patrick Kane", 11, 10, -3);
Player player5("Brandon Saad", 5,8, 8);
Player player6("Brandon Pirri",6,5,6);

cout<<"First Player Object"<<endl;
player1.printPlayer();
cout<<endl<<endl;
/*
player1.setGoals(2);
player1.printPlayer();
cout<<endl<<endl<<endl;

cout<<"Second Player Object"<<endl;
player2.printPlayer();
cout<<endl;endl;

player2.setName("Patrick Sharp");
player2.setGoals(7);
player2.setAssists(13);
player2.setRating(10);
player2.printPlayer();
cout<<endl;endl;

//**************************************************************************************
cout<<"Third Player Object"<<endl;
player3.printPlayer();
cout<<endl;

player3.setGoals(-8);
player3.setAssists(-2);
player3.printPlayer();
cout<<endl;endl;

//**************************************************************************************
cout<<"Fourth Player Object"<<endl;
player4.printPlayer();
cout<<endl<<endl;

player4.setAssists(3);
player4.setRating(3);
player4.printPlayer();
cout<<endl<<endl;

//**************************************************************************************
cout<<"Fifth Player Object"<<endl;
//cout only goals and plus minus?????????????????????????????????????????????????????????

player5.printPlayer();
cout<<endl<<endl;

//**************************************************************************************
cout<<"Sixth Player Object"<<endl;
player6.printPlayer();
cout<<endl;

player6.setAssists(-2);
player6.setAssists(4);
//player6. see out only assists??????????????????????????????????????????????????????????
player6.setRating(-4);
player6.printPlayer();
cout<<endl<<endl;


*/





//Test 2 -- constructor with arguments



// Setting Names, Goals, Assists and Rating


// getGoals, getAssists and getRating

//methods

Player::Player()
{
char setName('\0');

int setGoals = 0;
int setAssists = 0;
int setRatings = 0;
}


//******************************************************************************************************
Player::Player (const char[n], int g, int a, int r)
{
strcpy (playerName, char[n]);
setGoals(g);
setAssists(a);
setRatings(r);
}


//******************************************************************************************************
void Player::printPlayer()
{
cout<<""<<name<<endl;
int points;
points = goals + assists;
cout<<"Goals: "<<goals<<" Assists: "<<assists<<" Points: "<<points<<" Plus/Minus: "<<rating;
}

//******************************************************************************************************
void Player::setName(const char playerName[i])
{
int i;
while ( char [i] != 0)
{
playerName += name[i];
i++:
}
cout<<""<<name[i];
}

//******************************************************************************************************
void Player::setGoals (int goalsScored)
{
if (goalsScored >= 0)
goals+=goalsScored;

else
goals +=0;
cout<< "setGoals error: goals scored cannot be negative";
}

//******************************************************************************************************
void Player::setAssists(int assistsEarned)
{
if (assistsEarned >=0)
assists+=assistsEarned;

else
assists+=0;
cout<< "setAssist error: assists earned cannot be negative";
}
//******************************************************************************************************

void Player::setRating(int plusMinusChange)
{
if (plusMinusChange >= 0)
rating+=plusMinusChange;

else
rating+=0;
}
//*****************************************************************************************************

int Player::getGoals()
{
goalsScored= goals +goalsScored;
return goalsScored;
}

int Player::getAssists()
{
assistEarned = assists + assistsEarned;
return assistsEarned;
}

int Player::getRating()
{
plusMinusChange = rating + plusMinusChange;
return plusMinusChange;
}

Topic archived. No new replies allowed.