cout << "Riddle 1: I am lighter than a feather, yet no man can hold me for very long. What am I?\n";
string RIDDLEONE;
cin >> RIDDLEONE;
getline(cin,RIDDLEONE);
bool AnswerTrue = true;
bool AnswerFalse = false;
if (RIDDLEONE == "breath"){
do{
cout << "~~CORRECT~~"<<endl<<endl;
cout << SHIP <<"--\t\t\t\t"<<ENEMY<<endl;
cout << SHIP <<"\t--\t\t\t"<<ENEMY<<endl;
cout << SHIP <<"\t\t--\t\t"<<ENEMY<<endl;
cout << SHIP <<"\t\t\t--\t"<<ENEMY<<endl;
cout << SHIP <<"\t\t\t\t--"<<ENEMY<<endl;
cout << SHIP <<"\t\t\t\t"<<BOOM<<endl;
SCORE++;
ENEMY_KILLED++;
cout <<"\n\n";
AnswerTrue = false;
}while (AnswerTrue = true);
}else if (RIDDLEONE != "breath"){
while (AnswerFalse = false){
cout << "sorry thats incorrect! your ship is now being shot.\n\n";
cout << SHIP <<"\t\t\t\t--"<<ENEMY<<endl;
cout << SHIP <<"\t\t\t--\t"<<ENEMY<<endl;
cout << SHIP <<"\t\t--\t\t"<<ENEMY<<endl;
cout << SHIP <<"\t--\t\t\t"<<ENEMY<<endl;
cout << SHIP <<"--\t\t\t\t"<<ENEMY<<endl;
cout << BOOM <<"\t\t\t\t"<<ENEMY<<endl;
AnswerFalse = true;
}
}
}
int main()
{
cout << "Welcome To Alien-Destroyer By Polleo-Dev! \n\n";
cout << "Type '1' for the Rules and 2 to Start: ";
int CHOICE_MAIN;
cin >> CHOICE_MAIN;
switch(CHOICE_MAIN){
//rules
case 1:
cout << "How It Works: \n\n";
cout << "1: You will see your ship '>' and your enemy '@' you will need to figure solve a riddle to fire at your enemy./n If you get the riddle wrong, the enemy will shoot you and you will lose.\n\n";
cout << "\n\n";
cout << "________________________________________________________________________________";
main();
break;
//start
case 2:
start();
break;
}
return 0;
}
heres the problem, everytime i run it to test it, if i put in anything for the answer to the riddle, even the correct answer (breath) it just ends the program!...help?
#include <iostream>
#include <string>
usingnamespace std;
int start()
{
string SHIP;
SHIP = '()>'; // Use double quotes "()>" for string literals
char ENEMY = '@';
char BOOM = '*';
int SCORE = 0;
int ENEMY_KILLED = 0;
int BONUS = ENEMY_KILLED*2;
cout << "Score: "<<SCORE <<"\t"<<"Enemies Killed: "<<ENEMY_KILLED<<"\n\n";
cout << "::PLAYINGFIELD::"<<endl;
cout << SHIP << "\t\t\t\t" << ENEMY<<endl;
cout << "::PLAYINGFIELD::"<<endl<<endl;
cout << "Riddle 1: I am lighter than a feather, yet no man can hold me for very long. What am I?\n";
string RIDDLEONE;
cin >> RIDDLEONE;
getline(cin,RIDDLEONE); //¿how many times do you pretend to read the answer?
bool AnswerTrue = true; //obfuscated
bool AnswerFalse = false;
if (RIDDLEONE == "breath"){
do{
cout << "~~CORRECT~~"<<endl<<endl;
cout << SHIP <<"--\t\t\t\t"<<ENEMY<<endl;
cout << SHIP <<"\t--\t\t\t"<<ENEMY<<endl;
cout << SHIP <<"\t\t--\t\t"<<ENEMY<<endl;
cout << SHIP <<"\t\t\t--\t"<<ENEMY<<endl;
cout << SHIP <<"\t\t\t\t--"<<ENEMY<<endl;
cout << SHIP <<"\t\t\t\t"<<BOOM<<endl;
SCORE++;
ENEMY_KILLED++;
cout <<"\n\n";
AnswerTrue = false;
}while (AnswerTrue = true); // == is comparison. = is assignment ¿where does the condition change?
}elseif (RIDDLEONE != "breath"){
while (AnswerFalse = false){ //same as above
cout << "sorry thats incorrect! your ship is now being shot.\n\n";
cout << SHIP <<"\t\t\t\t--"<<ENEMY<<endl;
cout << SHIP <<"\t\t\t--\t"<<ENEMY<<endl;
cout << SHIP <<"\t\t--\t\t"<<ENEMY<<endl;
cout << SHIP <<"\t--\t\t\t"<<ENEMY<<endl;
cout << SHIP <<"--\t\t\t\t"<<ENEMY<<endl;
cout << BOOM <<"\t\t\t\t"<<ENEMY<<endl;
AnswerFalse = true;
}
}
//¿return?
}
int main()
{
cout << "Welcome To Alien-Destroyer By Polleo-Dev! \n\n";
cout << "Type '1' for the Rules and 2 to Start: ";
int CHOICE_MAIN;
cin >> CHOICE_MAIN;
switch(CHOICE_MAIN){
//rules
case 1:
cout << "How It Works: \n\n";
//next line is too long, you could divide it.
cout << "1: You will see your ship '>' and your enemy '@' you will need to figure solve a riddle to fire at your enemy./n If you get the riddle wrong, the enemy will shoot you and you will lose.\n\n";
cout << "\n\n";
cout << "________________________________________________________________________________";
main(); //error: ISO C++ forbids taking address of function ‘::main’. Use a loop instead
break;
//start
case 2:
start();
break;
}
return 0;
}