我似乎无法让这些 if 语句按预期工作。无论我输入“字符串答案”什么,它总是跳到第一个 IF 语句,其中条件设置为仅在答案正好是“n”或“N”或答案正好是“y”的块或“是”。如果您输入任何其他内容,它应该返回 0。
// Game Recap function, adds/subtracts player total, checks for deposit total and ask for another round
int gameRecap() {
string answer;
answer.clear();
cout << endl << "---------------" << endl;
cout << "The winner of this Game is: " << winner << endl;
cout << "Player 1 now has a total deposit of: " << deposit << " credits remaining!" << endl;
cout << "-------------------------" << endl;
if (deposit < 100) {
cout << "You have no remaining credits to play with" << endl << "Program will now end" << endl;
return 0;
}
else if (deposit >= 100) {
cout << "Would you like to play another game? Y/N" << endl;
cin >> answer;
if (answer == ("n") || ("N")) {
cout << "You chose no" << endl;
return 0;
}
else if (answer == ("y") || ("Y")) {
cout << "You chose YES" << endl;
currentGame();
}
else {
return 0;
}
return 0;
}
else {
return 0;
}
return 0;
}