player.cpp
/*
Programmer: Jennifer Leopold
Date: April 6, 2018
File: player.cpp
Purpose: This file contains the definitions of the functions
for the Player class.
*/
#include "player.h"
using namespace std;
Player::Player()
{
m_name = "";
m_pawn = DEFAULT_PAWN;
m_numLives = INIT_NUM_LIVES;
}
Player::Player(const string userName, const Pawn userPawn)
{
m_name = userName;
m_pawn = userPawn;
m_path = Path();
m_numLives = INIT_NUM_LIVES;
}
ostream& operator << (ostream& outs, const Player& p)
{
outs << "\nPlayer " << p.m_name
<< " is the " << p.PawnToString() << " pawn"
<< " and has " << p.m_numLives << " remaining lives.\n"
<< "This player's path has the following non-BLANK "
<< "entries:\n";
outs << p.m_path;
outs << endl;
return(outs);
}
bool Player::move(unsigned int numSpaces)
{
return(m_path.incrementCurrentPosition(numSpaces));
}