The main problem is most likely here:
void doWork(Player playerIn) {
You pass playerIn by value, which means that a copy of the object will be made. Any changes you make to it don't leave the function. If you want to modify the original object, you need to pass by reference:
Player& playerIn
There's some other strange things going on. For example, you seed the random number generator in several places, but you should have just one call
srand(time(NULL)); at the beginning of your program.
The
switch(random) in the constructor is also a bit strange, since it doesn't do anything (unless you wanted to add more positions later).
addMoney and addTime seem a bit verbose; you can write
1 2
|
money+=amount;
return money;
|
or even
return money+=amount;
The getters should be const, as they don't modify the Player object.
toString() should
return a string, not print something. You can achieve that by sending the output to a stringstream object instead of cout and returning the result at the end.
And in this line you actually create two player objects:
Player p = Player();
Player() creates a temporary player object and then copy constructs p with it.
Player p; is sufficient.