So I have a function that looks like this at the moment:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
void Player::Betting () {
do {
std::cout << "\n Place your bets: ";
std::cin >> myBet;
if (myBet <= myMoney) {
std::cout << "\n Thank you, sir.\n";
}
else
std::cout << "\n I'm sorry sir, but you do not have that much money.\n";
} while (myBet > myMoney);
myMoney -= myBet;
}
|
I have another class, Table, which handles most things related to the actual gaming processes (the Player class simply handles his own money). The Player class only has two data members:
myBet and
myMoney, so it would make sense to have this function in that class, but its content suggests it might as well be in the Table class.
If I put it in the Table class, I would have to give the function the argument
(Player& aPlayer) and then use functions like
GetBet() and
GetMoney() to access the private data members of Player. Alternatively, I could simply make Betting a function of its own and declare it in the Player class as
void friend Betting(Player&);
Which would be preferable, in terms of "good" (object-oriented) programming? Member function in Player class, member function in Table class, or a friend function for Player class?