Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. void slots(double &dollars);
  8. int getRandomSym();
  9. char numToSym(int num);
  10.  
  11. int main()
  12. {
  13.     srand(time(NULL));
  14.     char runAgain = 'y';
  15.     double playerchip = 100;
  16.     int game = 0;
  17.  
  18.     while (runAgain != 'n')
  19.     {
  20.         cout << "Welcome let's lose money!" << endl;
  21.         cout << "1 for slots" << endl;
  22.         cout << "2 for blackjack" << endl;
  23.         cin >> game;
  24.  
  25.         switch (game)
  26.         {
  27.         case 1:
  28.             slots(playerchip);
  29.             break;
  30.         }
  31.  
  32.         cout << "Current Amount: $" << playerchip << endl;
  33.  
  34.         cout << "Play again?" << endl;
  35.         cin >> runAgain;
  36.         system("cls");
  37.     }
  38.  
  39.     return 0;
  40. }
  41.  
  42. void slots(double &dollars)
  43. {
  44.     double bet = 0;
  45.  
  46.     bool firstRow = false;
  47.     bool secondRow = false;
  48.     bool thirdRow = false;
  49.  
  50.     int p1 = 0;
  51.     int p2 = 0;
  52.     int p3 = 0;
  53.     int p4 = 0;
  54.     int p5 = 0;
  55.     int p6 = 0;
  56.     int p7 = 0;
  57.     int p8 = 0;
  58.     int p9 = 0;
  59.  
  60.     char s1 = ' ';
  61.     char s2 = ' ';
  62.     char s3 = ' ';
  63.     char s4 = ' ';
  64.     char s5 = ' ';
  65.     char s6 = ' ';
  66.     char s7 = ' ';
  67.     char s8 = ' ';
  68.     char s9 = ' ';
  69.  
  70.     p1 = getRandomSym();
  71.     p2 = getRandomSym();
  72.     p3 = getRandomSym();
  73.     p4 = getRandomSym();
  74.     p5 = getRandomSym();
  75.     p6 = getRandomSym();
  76.     p7 = getRandomSym();
  77.     p8 = getRandomSym();
  78.     p9 = getRandomSym();
  79.  
  80.     /*cout << p1 << " " << p2 << " " << p3 << endl;
  81.     cout << p4 << " " << p5 << " " << p6 << endl;
  82.     cout << p7 << " " << p8 << " " << p9 << endl;
  83.     cout << "--------------------------" << endl;*/
  84.  
  85.     s1 = numToSym(p1);
  86.     s2 = numToSym(p2);
  87.     s3 = numToSym(p3);
  88.     s4 = numToSym(p4);
  89.     s5 = numToSym(p5);
  90.     s6 = numToSym(p6);
  91.     s7 = numToSym(p7);
  92.     s8 = numToSym(p8);
  93.     s9 = numToSym(p9);
  94.  
  95.  
  96.     cout << "Welcome to Rainy Day Slots!" << endl;
  97.     cout << "How much would you like to bet:" << endl;
  98.     cin >> bet;
  99.  
  100.     if (bet > dollars)
  101.     {
  102.         cout << "You don't got the money for it!" << endl;
  103.     }
  104.     else
  105.     {
  106.         cout << s1 << " " << s2 << " " << s3 << endl;
  107.         cout << s4 << " " << s5 << " " << s6 << endl;
  108.         cout << s7 << " " << s8 << " " << s9 << endl;
  109.         cout << "--------------------------" << endl;
  110.  
  111.         if ((s1 == s2) && (s1 == s3))
  112.         {
  113.             cout << "First row all match!" << endl;
  114.             dollars += bet * 2;
  115.             firstRow = true;
  116.         }
  117.         else if ((s2 == s1) && (s2 == s3))
  118.         {
  119.             cout << "First row all match!" << endl;
  120.             dollars += bet * 2;
  121.             firstRow = true;
  122.         }
  123.         else if ((s3 == s1) && (s3 == s2))
  124.         {
  125.             cout << "First row all match!" << endl;
  126.             dollars += bet * 2;
  127.             firstRow = true;
  128.         }
  129.         else if ((s1 == s2) && (s3 == 'X'))
  130.         {
  131.             cout << "First row all match!" << endl;
  132.             dollars += bet * 2;
  133.             firstRow = true;
  134.         }
  135.         else if ((s1 == s3) && (s2 == 'X'))
  136.         {
  137.             cout << "First row all match!" << endl;
  138.             dollars += bet * 2;
  139.             firstRow = true;
  140.         }
  141.         else if ((s2 == s1) && (s3 == 'X'))
  142.         {
  143.             cout << "First row all match!" << endl;
  144.             dollars += bet * 2;
  145.             firstRow = true;
  146.         }
  147.         else if ((s2 == s3) && (s1 == 'X'))
  148.         {
  149.             cout << "First row all match!" << endl;
  150.             dollars += bet * 2;
  151.             firstRow = true;
  152.         }
  153.         else if ((s3 == s1) && (s2 == 'X'))
  154.         {
  155.             cout << "First row all match!" << endl;
  156.             dollars += bet * 2;
  157.             firstRow = true;
  158.         }
  159.         else if ((s3 == s2) && (s1 == 'X'))
  160.         {
  161.             cout << "First row all match!" << endl;
  162.             dollars += bet * 2;
  163.             firstRow = true;
  164.         }
  165.         else if ((s2 == 'X') && (s3 == 'X'))
  166.         {
  167.             cout << "First row all match!" << endl;
  168.             dollars += bet * 2;
  169.             firstRow = true;
  170.         }
  171.         else if ((s1 == 'X') && (s3 == 'X'))
  172.         {
  173.             cout << "First row all match!" << endl;
  174.             dollars += bet * 2;
  175.             firstRow = true;
  176.         }
  177.         else if ((s1 == 'X') && (s2 == 'X'))
  178.         {
  179.             cout << "First row all match!" << endl;
  180.             dollars += bet * 2;
  181.             firstRow = true;
  182.         }
  183.         else if ((s1 == 'X') && (s2 == 'X') && (s3 == 'X'))
  184.         {
  185.             cout << "First row all match!" << endl;
  186.             dollars += bet * 2;
  187.             firstRow = true;
  188.         }
  189.  
  190.         if ((s4 == s5) && (s4 == s6))
  191.         {
  192.             cout << "Second row all match!" << endl;
  193.             dollars += bet * 2;
  194.             secondRow = true;
  195.         }
  196.         else if ((s5 == s4) && (s5 == s6))
  197.         {
  198.             cout << "Second row all match!" << endl;
  199.             dollars += bet * 2;
  200.             secondRow = true;
  201.         }
  202.         else if ((s6 == s4) && (s6 == s5))
  203.         {
  204.             cout << "Second row all match!" << endl;
  205.             dollars += bet * 2;
  206.             secondRow = true;
  207.         }
  208.         else if ((s4 == s5) && (s6 == 'X'))
  209.         {
  210.             cout << "Second row all match!" << endl;
  211.             dollars += bet * 2;
  212.             secondRow = true;
  213.         }
  214.         else if ((s4 == s6) && (s5 == 'X'))
  215.         {
  216.             cout << "Second row all match!" << endl;
  217.             dollars += bet * 2;
  218.             secondRow = true;
  219.         }
  220.         else if ((s5 == s4) && (s6 == 'X'))
  221.         {
  222.             cout << "Second row all match!" << endl;
  223.             dollars += bet * 2;
  224.             secondRow = true;
  225.         }
  226.         else if ((s5 == s6) && (s4 == 'X'))
  227.         {
  228.             cout << "Second row all match!" << endl;
  229.             dollars += bet * 2;
  230.             secondRow = true;
  231.         }
  232.         else if ((s6 == s4) && (s5 == 'X'))
  233.         {
  234.             cout << "Second row all match!" << endl;
  235.             dollars += bet * 2;
  236.             secondRow = true;
  237.         }
  238.         else if ((s6 == s5) && (s4 == 'X'))
  239.         {
  240.             cout << "Second row all match!" << endl;
  241.             dollars += bet * 2;
  242.             secondRow = true;
  243.         }
  244.         else if ((s5 == 'X') && (s6 == 'X'))
  245.         {
  246.             cout << "Second row all match!" << endl;
  247.             dollars += bet * 2;
  248.             secondRow = true;
  249.         }
  250.         else if ((s4 == 'X') && (s6 == 'X'))
  251.         {
  252.             cout << "Second row all match!" << endl;
  253.             dollars += bet * 2;
  254.             secondRow = true;
  255.         }
  256.         else if ((s4 == 'X') && (s5 == 'X'))
  257.         {
  258.             cout << "Second row all match!" << endl;
  259.             dollars += bet * 2;
  260.             secondRow = true;
  261.         }
  262.         else if ((s4 == 'X') && (s5 == 'X') && (s6 == 'X'))
  263.         {
  264.             cout << "Second row all match!" << endl;
  265.             dollars += bet * 2;
  266.             secondRow = true;
  267.         }
  268.  
  269.         if ((s7 == s8) && (s7 == s9))
  270.         {
  271.             cout << "Third row all match!" << endl;
  272.             dollars += bet * 2;
  273.             thirdRow = true;
  274.         }
  275.         else if ((s8 == s7) && (s8 == s9))
  276.         {
  277.             cout << "Third row all match!" << endl;
  278.             dollars += bet * 2;
  279.             thirdRow = true;
  280.         }
  281.         else if ((s9 == s7) && (s9 == s8))
  282.         {
  283.             cout << "Third row all match!" << endl;
  284.             dollars += bet * 2;
  285.             thirdRow = true;
  286.         }
  287.         else if ((s7 == s8) && (s9 == 'X'))
  288.         {
  289.             cout << "Third row all match!" << endl;
  290.             dollars += bet * 2;
  291.             thirdRow = true;
  292.         }
  293.         else if ((s7 == s9) && (s8 == 'X'))
  294.         {
  295.             cout << "Third row all match!" << endl;
  296.             dollars += bet * 2;
  297.             thirdRow = true;
  298.         }
  299.         else if ((s8 == s7) && (s9 == 'X'))
  300.         {
  301.             cout << "Third row all match!" << endl;
  302.             dollars += bet * 2;
  303.             thirdRow = true;
  304.         }
  305.         else if ((s8 == s9) && (s7 == 'X'))
  306.         {
  307.             cout << "Third row all match!" << endl;
  308.             dollars += bet * 2;
  309.             thirdRow = true;
  310.         }
  311.         else if ((s9 == s7) && (s8 == 'X'))
  312.         {
  313.             cout << "Third row all match!" << endl;
  314.             dollars += bet * 2;
  315.             thirdRow = true;
  316.         }
  317.         else if ((s9 == s8) && (s7 == 'X'))
  318.         {
  319.             cout << "Third row all match!" << endl;
  320.             dollars += bet * 2;
  321.             thirdRow = true;
  322.         }
  323.         else if ((s8 == 'X') && (s9 == 'X'))
  324.         {
  325.             cout << "Third row all match!" << endl;
  326.             dollars += bet * 2;
  327.             thirdRow = true;
  328.         }
  329.         else if ((s7 == 'X') && (s9 == 'X'))
  330.         {
  331.             cout << "Third row all match!" << endl;
  332.             dollars += bet * 2;
  333.             thirdRow = true;
  334.         }
  335.         else if ((s7 == 'X') && (s8 == 'X'))
  336.         {
  337.             cout << "Third row all match!" << endl;
  338.             dollars += bet * 2;
  339.             thirdRow = true;
  340.         }
  341.         else if ((s7 == 'X') && (s8 == 'X') && (s9 == 'X'))
  342.         {
  343.             cout << "Third row all match!" << endl;
  344.             dollars += bet * 2;
  345.             thirdRow = true;
  346.         }
  347.  
  348.  
  349.         if (firstRow == false && secondRow == false && thirdRow == false)
  350.         {
  351.             dollars -= bet;
  352.         }
  353.     }
  354. }
  355.  
  356. int getRandomSym()
  357. {
  358.     int sym = rand() % 6 + 1;
  359.  
  360.     return sym;
  361. }
  362.  
  363. char numToSym(int num)
  364. {
  365.     char sym = ' ';
  366.     switch (num)
  367.     {
  368.     case 1:
  369.         sym = 'A';
  370.         break;
  371.     case 2:
  372.         sym = 'B';
  373.         break;
  374.     case 3:
  375.         sym = 'C';
  376.         break;
  377.     case 4:
  378.         sym = 'D';
  379.         break;
  380.     case 5:
  381.         sym = 'E';
  382.         break;
  383.     case 6:
  384.         sym = 'X';
  385.         break;
  386.     }
  387.  
  388.     return sym;
  389. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement