基本上我正在生成扑克游戏的骨架。我只是试图让投注系统崩溃。我在代码中偶然发现的是我的 int 的值不断恢复到它们的原始状态(100)。我显然做错了什么,这是我的问题(我做错了什么,我能做些什么来解决它)。
class BetSys
{
public:
int loseM;
int bet;
int earn;
int money;
int Tmoney;
int Omoney;
void Loop();
void Flow();
void Game();
};
void BetSys::Loop()
{
int Omoney = 100;
int bet = 0;
int loseM = 0;
loseM = loseM + bet;
cout << "Your start money = " << Omoney << " \n\n\n" << endl;
Game();
}
void BetSys::Game()
{
bool win;
bool lose;
int Omoney = 100;
int* PointMon = &Omoney;
int money = 0;
int Tmoney = 0;
int bet = 0;
int earn = (bet * 2) + *PointMon;
int loseM = 0;
cout << "Place your bet here!" << endl;
cin >> bet;
money = *PointMon - bet;
cout << "Your total money after bet is " << money << "\n\n";
//betP(int money)
//{
// money - bet = money;
//}
if (bet > 10)
{
win = true;
if (win)
{
cout << "YOU WIN! \n\n" << endl;
/*earn = (earn) + Omoney;*/
cout << "You earned: \n" << earn;
Tmoney = earn + (*PointMon - bet);
cout << "\nTotal money: \n" << Tmoney;
}
}
else if (bet <= 10)
{
lose = true;
if (lose)
{
cout << "You Lose!\n\n\n" << endl;
int Mlose= loseM + bet;
cout << "You lost: \n" << Mlose;
Tmoney = loseM + (*PointMon - bet);
cout << "\nTotal money: \n" << Tmoney;
cout << "\n\n\n\n";
*PointMon = Tmoney;
//for(int i = 0, i > 20, i++)
//{
// int i=10;
//}
Flow();
}
}
}
void BetSys::Flow()
{
Game();
}