Advertisement
JustACodingStudent

Crystal Ball (School Project)

Apr 3rd, 2014
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. #include <string>
  5. using namespace std;
  6.  
  7. //Randomizes the good message.
  8. void GoodMessage()
  9. {
  10.     int seedg;
  11.     seedg = 1 + rand()%5;
  12.     if(seedg == 1)
  13.         cout << "You will marry Ms. Teacher.\n";
  14.     else if(seedg == 2)
  15.         cout << "You'll become a millionaire.\n";
  16.     else if(seedg == 3)
  17.         cout << "You'll date a super-model.\n";
  18.     else if(seedg == 4)
  19.         cout << "You're gonna find the cure for cancer.\n";
  20.     else
  21.         cout << "You'll become a wizard.\n";
  22. }
  23. //Randomizes the bad message.
  24. void BadMessage()
  25. {
  26.     int seedb;
  27.     seedb = 1 + rand()%5;
  28.     if(seedb == 1)
  29.         cout << "You'll become ugly.\n";
  30.     else if(seedb == 2)
  31.         cout << "You'll go into poverty.\n";
  32.     else if(seedb == 3)
  33.         cout << "You'll die alone. D:\n";
  34.     else if(seedb == 4)
  35.         cout << "You're gonna get robbed.\n";
  36.     else
  37.         cout << "You'll become a wizard, but then a spell will backfire and you'll die.\n";
  38. }
  39. //Randomizes the 8-Ball.
  40.  
  41. void EightBall()
  42. {
  43.     int seed8;
  44.     seed8 = 1 + rand()%3;
  45.     if(seed8 == 1)
  46.         cout << "Yes.\n";
  47.     else if(seed8 == 2)
  48.         cout << "Maybe.\n";
  49.     else
  50.         cout << "No.\n";
  51. }
  52.  
  53. int main()
  54. {
  55.     int seed, mode, trubd;
  56.     char response;
  57.     string q;
  58.     trubd = 0;
  59.     //Allows user to choose between Crystal or 8 Ball.
  60.     cout << "Select mode:\n";
  61.     cout << "     1) Crystal Ball\n";
  62.     cout << "     2) Magic 8 Ball\n";
  63.     cin >> mode;
  64.     if(mode == 1){
  65.         //Crystal Ball
  66.       do{
  67.         srand(time(0));
  68.         seed = rand()%2;
  69.         system("cls");
  70.         cout << "Welcome to my crystal ball. Give it a rub.\n";
  71.         system("pause");
  72.         system("cls");
  73.         if(seed == 0){
  74.             GoodMessage();
  75.         }
  76.         else{
  77.             BadMessage();
  78.         }
  79.         trubd += 1;
  80.         //Displays the times rubbed and a custom message based on the times rubbed.
  81.         cout << "Times rubbed: " << trubd << endl;
  82.         if(trubd == 3){
  83.             cout << "Good for you, knowing your future.\n";
  84.         }
  85.         else if(trubd == 6){
  86.             cout << "Wow. You REALLY wanna know your fortunes huh?\n";
  87.         }
  88.         else if(trubd == 10){
  89.             cout << "Dear god. Get a life and live in the present. -_-\n";
  90.         }
  91.         else if(trubd > 10){
  92.             cout << "Please go away. You're bugging me.\n";
  93.         }
  94.         cout << "\nWould you like to rub again? (y/n): ";
  95.         cin >> response;
  96.       }while(response == 'y');
  97.     }
  98.     else{
  99.         //8-Ball
  100.         do{
  101.             srand(time(0));
  102.             system("cls");
  103.             cout << "What is your question?\n";
  104.             cin.ignore();
  105.             getline(cin, q);
  106.             EightBall();
  107.             cout << "\nWould you like to ask another question? (y/n): ";
  108.             cin >> response;
  109.         }while(response == 'y');
  110.     }
  111.     system("pause");
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement