これらの 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;
}