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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
|
//end game!
cout << " Only one way to see if I was correct, lets add "
<< "\n all these numbers together!" << endl << endl;
cout << digit1 << endl << "\t+" << endl << digit2 << endl
<< "\t+" << endl << digit3 << endl << "\t+" << endl
<< digit4 << endl << "\t+" << endl
<< digit5 << endl << endl;
cout << " Total: " << (digit1 + digit2 + digit3 + digit4 + digit5)
<< endl << endl;
cout << " Guess I win ^_^, Good bye...unless you wish to play again (1)."
<< endl << endl;
cin >> playagain;
} while (playagain == 1);
}
void treasure()
{
do
{
int x = 30, y = 30; // Explorer’s coordinates
int x1, y1; // Treasure’s coordinates
char dir = 'a';
float distance;
bool treasure = false;
srand(time(0)); // secretly seed the rand function !
x1 = rand() % 30 + 1; // x1 is randomly set to a number between 1 //and 30
y1 = rand() % 30 + 1; // y1 is randomly set to a number between //1and 30;
//write loop to find the treasure
char d; //direction user is heading
int z; //for while loop
int count; //how many steps were taken
z = 0;
count = 0;
//directions for the game
cout << " Argh maties! There is hidden booty around here, I can smell it!"
<< "\n I'll tell you what if you find the treasure you can keep it!"
<< endl
<< "\n To help you start I'll let you know that your coordinates are (30,30)."
<< "\n You can only move North, South, West or East."
<< endl
<< "\n Everytime you move in a direction I'll let you know your coordinates and"
<< "\n how close you are to the treasure."
<< "\n When your coordinate is the same as the Treasures, you win! Now Lets Start!"
<< endl << endl << endl;
//loop statement starts
while (z != 1)
{
cout << " Please enter (n,s,e,w) to go towards the corresponding direction or"
<< "\n (x) to exit: ";
cin >> d;
//increasing y or x depending on direction (d) input with ifs
if (d == 'n')
{
y++;
}
else if (d == 's')
{
y--;
}
else if (d == 'e')
{
x++;
}
else if (d == 'w')
{
x--;
}
//calc distance and increase step count
distance = sqrt(static_cast<float>((x - x1)*(x - x1) + (y - y1)*(y - y1)));
count++;
//giving player hints
cout << " Your location is: (" << x << "," << y << ";" << endl << endl;
cout << " Your distance from the treasure is " << distance << "." << endl << endl;
if (distance > 8)
{
cout << " You are too far from the treasure." << endl << endl;
}
else if (4 < distance && 8 <= distance)
{
cout << " You are far from the treasure." << endl << endl;
}
else if (4 <= distance && distance > 0)
{
cout << " You are getting closer to the treasure." << endl << endl;
}
//found treasure, end loop
else if (distance == 0)
{
cout << " Congratulations, you have reached the treasure!"
<< "\n You have reached the treasure in: "
<< count << " steps." << endl << endl;
break;
}
cout << " Do you wish to play again (1)?" << endl << " ";
cin >> playagain;
cout << endl << endl;
} //end of while loop
} while (playagain == 1);
}
void psychic()
{
unsigned seed;
char life, response;
bool again = true;
cout << " Welcome to the Matrix.\n"
<< " You have been automaticly connected to the Psychic Computer Network.\n"
<< " My name is Dionne, and I will be your psychic computer guide.\n"
<< endl << " Before we continute please enter a number: ";
std::cin >> seed;
srand(seed);
while (!std::cin)
{
std::cin.clear();
cout << "Please, enter only an INTEGER> " << flush;
std::cin >> seed;
}
cout << "\n Thank you. Lets move on.\n";
do
{
cout << " Please enter an 'R' for a prediction on your relationships.\n"
<< " Please enter an 'E' for a prediction on school life.\n"
<< " And finally you can enter 'D' for a prediction on your financial situation.\n"
<< endl << " ";
std::cin >> life;
if (life == 'R' || life == 'r')
{
int x = rand() % 5 + 1;
switch (x)
{
case 1:
cout << "\n Roses are red, voilets are not blue,"
<< "\n smile today if you want your true love to find you.";
break;
case 2:
cout << "\n Walk up to your crush, smile, extend your hand and say"
<< "\n hello and your day will never be the same.";
break;
case 3:
cout << "\n Don't be shy, take some risk in your relationships, today is the day.";
break;
case 4:
cout << "\n Go to a comedy club, watch something funny or listen to something funny, "
<< "\n this will help strengthen your relationship.";
break;
case 5:
cout << "\n Step outside your comfort zone if you want to meet new people.";
break;
}
}
else if (life == 'E' || life == 'e')
{
int y = rand() % 5 + 1;
switch (y)
{
case 1:
cout << "\n You will get a B + if you study for that upcoming test.";
break;
case 2:
cout << "\n School will be closed soon.";
break;
case 3:
cout << "\n Your teachers will assign homework for thanksgiving.";
break;
case 4:
cout << "\n Find a study buddy, they will be the reason you start to excel in class.";
break;
case 5:
cout << "\n Review your previous class notes so you wont be surprise of the pop quiz.";
break;
}
}
else if (life == 'D' || life == 'd')
{
int z = rand() % 5 + 1;
switch (z)
{
case 1:
cout << "\n Invest in yourself and in life if you wish to be succesful.";
break;
case 2:
cout << "\n Donate a dollar, you will find a bill worth way more later.";
break;
case 3:
cout << "\n You can not be cheap with everything,"
<< "\n especially when it comes to your health and needs.";
break;
case 4:
cout << "\n Put your needs over your wants if you wish to be financly regret free.";
break;
case 5:
cout << "\n Learn to cook, the fast food you eat is doing a lot "
<< "\n more than satisfying your hunger.";
break;
}
}
else
{
std::cin.clear();
cout << "Please, enter only an R, E or D. " << flush;
std::cin >> life;
}
cout << "\n\n Would you like another prediction? Y/N" << endl << endl << " ";
std::cin >> response;
cout << endl;
if (response == 'n' || response == 'N')
{
cout << " You have been disconnected from the Psychic Computer Network..." << endl;
again = false;
}
else again = true;
} while (again == true);
}
|