这对我来说是一个不断增长的刺激源,当我按下相应的按钮时(他们在上面初始化)他们实际上没有执行,我被困在菜单中。
我确信这很荒谬,我只是没有看到它。
编辑:根据要求添加更多
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);
答案 0 :(得分:5)
choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
应该是
poker_choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
答案 1 :(得分:0)
因为你提到这是在一个方法中,
这里有几件事要检查;
- 进入方法后,只需打印poker_choice,看看你的值是否正确传递。
- 检查所有案例FIVE_CARD,TEXAS是否都被声明为相同数据类型的常量。
答案 2 :(得分:0)
您的错误似乎就在这一行:
choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
您在poker_choice
中测试了switch
,但是您将值分配给choice
。
应该是:
poker_choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
// ^^^^^^
switch(poker_choice)
// ...