Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- void slots(double &dollars);
- int getRandomSym();
- char numToSym(int num);
- int main()
- {
- srand(time(NULL));
- char runAgain = 'y';
- double playerchip = 100;
- int game = 0;
- while (runAgain != 'n')
- {
- cout << "Welcome let's lose money!" << endl;
- cout << "1 for slots" << endl;
- cout << "2 for blackjack" << endl;
- cin >> game;
- switch (game)
- {
- case 1:
- slots(playerchip);
- break;
- }
- cout << "Current Amount: $" << playerchip << endl;
- cout << "Play again?" << endl;
- cin >> runAgain;
- system("cls");
- }
- return 0;
- }
- void slots(double &dollars)
- {
- double bet = 0;
- bool firstRow = false;
- bool secondRow = false;
- bool thirdRow = false;
- int p1 = 0;
- int p2 = 0;
- int p3 = 0;
- int p4 = 0;
- int p5 = 0;
- int p6 = 0;
- int p7 = 0;
- int p8 = 0;
- int p9 = 0;
- char s1 = ' ';
- char s2 = ' ';
- char s3 = ' ';
- char s4 = ' ';
- char s5 = ' ';
- char s6 = ' ';
- char s7 = ' ';
- char s8 = ' ';
- char s9 = ' ';
- p1 = getRandomSym();
- p2 = getRandomSym();
- p3 = getRandomSym();
- p4 = getRandomSym();
- p5 = getRandomSym();
- p6 = getRandomSym();
- p7 = getRandomSym();
- p8 = getRandomSym();
- p9 = getRandomSym();
- /*cout << p1 << " " << p2 << " " << p3 << endl;
- cout << p4 << " " << p5 << " " << p6 << endl;
- cout << p7 << " " << p8 << " " << p9 << endl;
- cout << "--------------------------" << endl;*/
- s1 = numToSym(p1);
- s2 = numToSym(p2);
- s3 = numToSym(p3);
- s4 = numToSym(p4);
- s5 = numToSym(p5);
- s6 = numToSym(p6);
- s7 = numToSym(p7);
- s8 = numToSym(p8);
- s9 = numToSym(p9);
- cout << "Welcome to Rainy Day Slots!" << endl;
- cout << "How much would you like to bet:" << endl;
- cin >> bet;
- if (bet > dollars)
- {
- cout << "You don't got the money for it!" << endl;
- }
- else
- {
- cout << s1 << " " << s2 << " " << s3 << endl;
- cout << s4 << " " << s5 << " " << s6 << endl;
- cout << s7 << " " << s8 << " " << s9 << endl;
- cout << "--------------------------" << endl;
- if ((s1 == s2) && (s1 == s3))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s2 == s1) && (s2 == s3))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s3 == s1) && (s3 == s2))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s1 == s2) && (s3 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s1 == s3) && (s2 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s2 == s1) && (s3 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s2 == s3) && (s1 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s3 == s1) && (s2 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s3 == s2) && (s1 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s2 == 'X') && (s3 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s1 == 'X') && (s3 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s1 == 'X') && (s2 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- else if ((s1 == 'X') && (s2 == 'X') && (s3 == 'X'))
- {
- cout << "First row all match!" << endl;
- dollars += bet * 2;
- firstRow = true;
- }
- if ((s4 == s5) && (s4 == s6))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s5 == s4) && (s5 == s6))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s6 == s4) && (s6 == s5))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s4 == s5) && (s6 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s4 == s6) && (s5 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s5 == s4) && (s6 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s5 == s6) && (s4 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s6 == s4) && (s5 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s6 == s5) && (s4 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s5 == 'X') && (s6 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s4 == 'X') && (s6 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s4 == 'X') && (s5 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- else if ((s4 == 'X') && (s5 == 'X') && (s6 == 'X'))
- {
- cout << "Second row all match!" << endl;
- dollars += bet * 2;
- secondRow = true;
- }
- if ((s7 == s8) && (s7 == s9))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s8 == s7) && (s8 == s9))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s9 == s7) && (s9 == s8))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s7 == s8) && (s9 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s7 == s9) && (s8 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s8 == s7) && (s9 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s8 == s9) && (s7 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s9 == s7) && (s8 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s9 == s8) && (s7 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s8 == 'X') && (s9 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s7 == 'X') && (s9 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s7 == 'X') && (s8 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- else if ((s7 == 'X') && (s8 == 'X') && (s9 == 'X'))
- {
- cout << "Third row all match!" << endl;
- dollars += bet * 2;
- thirdRow = true;
- }
- if (firstRow == false && secondRow == false && thirdRow == false)
- {
- dollars -= bet;
- }
- }
- }
- int getRandomSym()
- {
- int sym = rand() % 6 + 1;
- return sym;
- }
- char numToSym(int num)
- {
- char sym = ' ';
- switch (num)
- {
- case 1:
- sym = 'A';
- break;
- case 2:
- sym = 'B';
- break;
- case 3:
- sym = 'C';
- break;
- case 4:
- sym = 'D';
- break;
- case 5:
- sym = 'E';
- break;
- case 6:
- sym = 'X';
- break;
- }
- return sym;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement