这对我来说是一个越来越大的恼怒的来源,当我按下相应的按钮(它们在上面初始化),它们实际上没有执行,我被卡在菜单里。
我肯定这太简单了,我只是没看到而已。
编辑:根据请求添加更多内容
const int POKER = 1;
const int EVAL = 2;
const int EXIT = 3;
const char FIVE_CARD = 'a';
const char TEXAS = 'b';
const char OMAHA = 'c';
const char SEVEN_CARD = 'd';
const char GO_BACK = 'e';
const char MENU[] = "\nPlease choose an option from the following:\n"
"1) Play Poker\n2) Set Evaluation Method\n3) Quit\n: ";
const char POKER_MENU[] = "\nPlease choose your game:\n"
"a) 5 Card Draw\nb) Texas Hold 'Em\nc) Omaha High\n"
"d) 7 Card Stud\ne) Go back\n: ";
int main()
{
int choice = 0;
char poker_choice;
do
{
choice = askForInt(MENU, EXIT, POKER);
switch(choice)
{
case POKER :
do
{
choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
switch(poker_choice)
{
case FIVE_CARD :
std::cout << "Not implemented yet" << std::endl;
break;
case TEXAS :
std::cout << "Not implemented yet" << std::endl;
break;
case OMAHA :
std::cout << "Not implemented yet" << std::endl;
break;
case SEVEN_CARD :
std::cout << "Not implemented yet" << std::endl;
break;
case GO_BACK :
break;
}
}while(poker_choice != GO_BACK);
case EVAL :
std::cout << "Not implemented yet" << std::endl;
break;
case EXIT :
break;
}
}while(choice != EXIT);发布于 2013-09-10 13:56:01
choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
应该是
poker_choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
发布于 2013-09-10 13:51:19
既然你说这是在一个方法里,
这里几乎没有什么东西需要检查;
发布于 2013-09-10 14:01:38
您的错误似乎出现在这条线上:
choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);在您的poker_choice中测试switch,但是将值分配给choice。
它应该是:
poker_choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
// ^^^^^^
switch(poker_choice)
// ...https://stackoverflow.com/questions/18720695
复制相似问题