1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#include <iostream>
#include <string> //declarations
#include <limits>
using namespace std;
char response;
char response2;
int response3;
string guess1; //variable declarations
string guess2;
string guess3;
int lose(); //function prototypes
int win();
class Game3 {
public:
void guessThree(){
cout << "Alright, last one. 'neltat'";
cin >> guess3; //user input
if (guess3 == "talent" || guess3 == "Talent") { //correct input
cout << "That is correct!\n";
cout << "Wow, you're really, really good!\n";
win(); //calls win function which is end of program
}
else { //incorrect input
cout << "No, sorry, that's not correct.\n";
cout << "Exiting...\n";
lose(); //calls lose function which is end of program
}
}
};
class Game2 {
public:
void guessTwo(){
cout << "Alright, let's continue. 'hnarcb'";
cin >> guess2; // user input
if (guess2 == "branch" || guess2 == "Branch") { //this is the correct input
cout << "That is correct!\n";
cout << "Wow, you're good!\n";
Game3 guesscall3; // call class Game3
guesscall3.guessThree();
}
else { //incorrect input
cout << "No, sorry, that's not correct.\n";
cout << "Exiting...\n";
lose(); // calls lose function
}
}
};
class Game1{
public:
void guessOne(){
cout << "Alright, let's begin. 'mfsfiun'";
cin >> guess1; //user input
if (guess1 == "muffins" || guess1 == "Muffins") { //correct input
cout << "That is correct!\n";
cout << "Wow, you're good!\n";
Game2 guesscall2; // call class Game2
guesscall2.guessTwo();
}
else { //incorrect input
cout << "No, sorry, that's not correct.\n";
cout << "Exiting...\n";
lose(); // calls lose function
}
}
};
class Instructions { //first class that is called
public:
void playerInstructions(){
cout << "Alright, I'll give you a scrambled-up word "
<< "and you'll input the un-scrambled word.";
cout << "For example, 'fdoo' would be food!\n";
cout << "Do you still want to play?[Y/N]\n";
cin >> response2; //'Y' calls class Game1
if (response2 == 'Y' || response2 == 'y') {
cout << "Alrighty then!.\n";
Game1 guesscall1;
guesscall1.guessOne(); // call class Game1
}
else if (response2 == 'N' || response2 == 'n') { //'N' calls the lose function, ends program
cout << "Well, that's too bad.\n";
cout << "Exiting...\n";
lose(); //calls lose function which is the end of program
}
}
};
int main() //start of program
{
cout << "Hello.";
cout << "Would you like to play a game?[Y/N]\n";
cin >> response; //'Y' calls class instructions
if (response == 'Y' || response == 'y') {
cout << "Great! Let's begin.\n";
Instructions call1;
call1.playerInstructions(); //calls class instructions
}
else if (response == 'N' || response == 'n') { //'N' calls lose function, ends program
cout << "Well, that's too bad.\n";
cout << "Exiting...\n";
lose();
}
return 0;
}
int lose(){
cout << "Sorry, you lose. Better luck next time.\n";
cout << "Type anything and press enter to close";
cin >> response3;
return 0;
}
int win(){ //user only reaches this after class Game3 is completed
cout << "You are very excellent at this.\n";
cout << "You win!";
cout << "Type anything and press enter to close";
cin >> response3;
return 0;
}
|