我正在为我的 C++ 课程介绍用 C++ 制作一个扑克游戏(应该告诉你我只是一个初学者,所以请原谅这里有任何不好的程序员练习)。我目前正在开发投注系统,我很高兴它完成了我需要它做的事情。除了它不继续 - 游戏只是在手后重置。这是我的代码,我在想我需要创建单独的类,然后在主类中调用这些类,但我只是不确定这会有什么不同,如果是这样的话,我会删除这个问题。
{// ConsoleApplication71.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include "Bet.h"
using namespace std;
//Bet P = int betP(int money);
int main()
{
bool win;
bool lose;
int Omoney = 100;
int money = 0;
int Tmoney = 0;
int bet = 0;
int earn = (bet * 2) + Omoney;
int loseM = 0;
loseM = loseM + bet;
cout << "Your start money = " << Omoney << " \n\n\n" << endl;
cout << "Place your bet here!" << endl;
cin >> bet;
money = Omoney - bet;
cout << "Your total money after bet is " << money << "\n\n";
//betP(int money)
//{
// money - bet = money;
//}
if (bet > 10)
{
win = true;
if (win = true)
{
cout << "YOU WIN! \n\n" << endl;
/*earn = (earn) + Omoney;*/
cout << "You earned: \n" << earn;
Tmoney = earn + (Omoney - bet);
cout << "\nTotal money: \n" << Tmoney;
}
}
else if (bet <= 10)
{
lose = true;
if (lose = true)
{
cout << "You Lose!\n\n\n" << endl;
int Mlose= loseM + bet;
cout << "You lost: \n" << Mlose;
Tmoney = loseM + (Omoney - bet);
cout << "\nTotal money: \n" << Tmoney;
cout << "\n\n\n\n";
Omoney = Tmoney;
main();
}
}
cin.get();
cin.get();
return 0;
}