#include <iostream>
#include <string>
using namespace std;
int main() { //Program starts
cout << "-------------------------------" << endl;
cout << "Welcome to Ninjas vs. Samurais!" << endl; //The intro
cout << "-------------------------------" << endl;
string newAdventure;
string chosenKind;
cout << "Hello, new solder! Are you ready for your adventure to begin, yes or no?\n"; //Asks you if you are ready
cin >> newAdventure;//Takes in if you are ready or not
if (newAdventure == "yes" || newAdventure == "Yes" || newAdventure == "Yes!") { //Asks if they are ready
cout << "Great!\n" << endl;
}
else if (newAdventure == "no" || newAdventure == "No" || newAdventure == "No!") { //Asks if they are ready
cout << "Too bad!\n" << endl;
}
else {
cout << "Please type a yes or no answer!\n";
}
system("PAUSE");
return 0;
}
Kullanıcı geçerli bir yanıt girmediyse, bunları yeniden başlatmaya nasıl başlatabilirim? Bir döngü kullanmak zorunda mıyım? Eğer öyleyse, bunu nasıl yaparım?Oyun menülerini görüntülerken geçersiz girişler nasıl kullanılır?
'while'? ... – pfnuesel
@pfnuesel, demek istediğim, kullanıcı geçerli bir cevap girmezse, soruyu tekrar nasıl sorabilirim? –
Çıkış koşullu bir süre veya başka bir döngü türüne ihtiyacınız olacaktır. Bir sonraki sefer –