Projects ============ Roulette -------- .. code-block:: cpp :linenos: :class: scrollable-code #include #include #include #include #include using namespace std; // Generate random number (Roulette spin) int generatenum() { static random_device rd; static mt19937 gen(rd()); static uniform_int_distribution dist(0,37); return dist(gen); } // Figures out color each round based on number string getcolor(int number) { if (number == 0 || number == 37) return "Green"; static string colors[38] = { "Green", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red" }; return colors[number]; } // Display betting options with payout ratios void instructions() { cout << "================= ROULETTE BETTING OPTIONS =================" << endl; cout << "1. Red 1:1 - Bet that the number will be red" << endl; cout << "2. Black 1:1 - Bet that the number will be black" << endl; cout << "3. Odd 1:1 - Bet that the number will be odd" << endl; cout << "4. Even 1:1 - Bet that the number will be even" << endl; cout << "5. Low 1:1 - Bet that the number will be 1 to 18" << endl; cout << "6. High 1:1 - Bet that the number will be 19 to 36" << endl; cout << "7. Dozen 1 2:1 - Bet that the number will be 1 to 12" << endl; cout << "8. Dozen 2 2:1 - Bet that the number will be 13 to 24" << endl; cout << "9. Dozen 3 2:1 - Bet that the number will be 25 to 36" << endl; cout << "10. Column 1 2:1- Bet that the number will be in 1st column" << endl; cout << "11. Column 2 2:1- Bet that the number will be in 2nd column" << endl; cout << "12. Column 3 2:1- Bet that the number will be in 3rd column" << endl; cout << "13. Green 17:1 - Bet that the number will be 0 or 00" << endl; cout << "============================================================" << endl; cout << "Enter the number corresponding to your bet type." << endl; } // Bet result class class BetResult { public: bool win; int payout; }; // Check if user won BetResult result(int choice,int spin,const string &color) { BetResult r; if(choice == 1){ r.win = (color=="Red"); r.payout=1; } else if(choice == 2){ r.win = (color=="Black"); r.payout=1; } else if(choice == 3){ r.win = (spin!=0 && spin!=37 && spin%2==1); r.payout=1; } else if(choice == 4){ r.win = (spin!=0 && spin!=37 && spin%2==0); r.payout=1; } else if(choice == 5){ r.win = (spin>=1 && spin<=18); r.payout=1; } else if(choice == 6){ r.win = (spin>=19 && spin<=36); r.payout=1; } else if(choice == 7){ r.win = (spin>=1 && spin<=12); r.payout=2; } else if(choice == 8){ r.win = (spin>=13 && spin<=24); r.payout=2; } else if(choice == 9){ r.win = (spin>=25 && spin<=36); r.payout=2; } else if(choice == 10){ r.win = (spin%3==1); r.payout=2; } else if(choice == 11){ r.win = (spin%3==2); r.payout=2; } else if(choice == 12){ r.win = (spin%3==0); r.payout=2; } else if(choice == 13){ r.win = (spin==0 || spin==37); r.payout=17; } return r; } int main() { bool play = true; int resultnum, choice, bet, total; char again; int z=0; cout << "How much money will you be playing with? (# only, no $): "; cin >> total; while(play) { instructions(); cin >> choice; while(z<1) { cout << "\nHow much money would you like to bet? (ex:50)\nBet: "; cin >> bet; if(bet>total){ cout<<"Not enough money, enter different amount."<0){ cout<<"play again?(y/n): "; cin>>again; play = (again=='y'); } else { cout<<"No more money. Game over"<