Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std;
- int GetBet();
- string PullOne();
- int GetPayMultiplier(string s1, string s2, string s3);
- void Display(string s1, string s2, string s3, int winnings);
- int main()
- {
- int theBet = GetBet();
- srand (time (NULL));
- while (theBet != 0)
- {
- PullOne();
- string first = PullOne();
- PullOne();
- string second = PullOne();
- PullOne();
- string third = PullOne();
- int winnings = GetBet()*GetPayMultiplier(first, second, third);
- Display(first, second, third, winnings);
- }
- }
- int GetBet()
- {
- int theBet;
- cout << "Please place a bet from $1 to $100. Do not include $ in your input."
- " 0 to quit.\n";
- cin >> theBet;
- while (theBet > 100 || theBet < 0)
- {
- cout << "Please input a valid number\n";
- cin >> theBet;
- }
- if (theBet == 0)
- {
- cout << "Goodbye.";
- exit(0);
- }
- return (theBet);
- }
- string PullOne()
- {
- int slotChoices = 4;
- string slotPull[slotChoices];
- slotPull[0] = "cherries";
- slotPull[1] = "BAR";
- slotPull[2] = "space";
- slotPull[3] = "7";
- return slotPull[rand() % 4];
- }
- int GetPayMultiplier(string s1, string s2, string s3)
- {
- int multiplier;
- if (s1 == "cherries" && s2 != "cherries")
- multiplier = 3;
- else if (s1 == "cherries" && s2 == "cherries" && s3 != "cherries")
- multiplier = 10;
- else if (s1 == "cherries" && s2 == "cherries" && s3 == "cherries")
- multiplier = 20;
- else if (s1 == "BAR" && s2 == "BAR" && s3 == "BAR")
- multiplier = 35;
- else if (s1 == "7" && s2 == "7" && s3 == "7")
- multiplier = 50;
- return (multiplier);
- }
- void Display(string s1, string s2, string s3, int winnings)
- {
- cout << s1 << " " << s2 << " " << s3 << "\n";
- if (winnings == 0)
- cout << "Sorry, you didn't win anything. Please try again.\n";
- else cout << "You won $" << winnings << "!\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement