Hello everyone. I need some help on creating a slot machine. It needs to have the option of playing a three wheel & four wheel machine. I've created separate functions for those two. I think I understand the whole random generating concept, but I'm having a hard time figuring out how to get the generator to randomize words ("bar," "cherry," "seven," etc.) instead of numbers. I know this isn't perfect, since it's far from finished. But if I can get a nice little push in the right direction, and any suggestions on what I could do differently (in anything I've done), I'd appreciate it. Currently not getting any errors, so that's a plus!
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
int credits = 0;
int bet = 0;
int winnings = 0;
string chr1;
string chr2;
string chr3;
string chr4;
void menu(char decision);
void earnings();
void three(); // for three wheel slot machine.
void four(); // for four wheel slot machine.
int main()
{
char pay = 0;
char decision;
cout << "FANCY NAME SLOT MACHINE!\n\n";
cout << "'3' - start the three wheel slot machine.\n'4' - start the four wheel slot machine.\n"
"'T' - access the pay table.\n'B' - place your bet(s).\n"
"'S' - press your luck, spin the wheel\n'P' - collect your earnings & cash out.\n"
"'Q' - quit the game.\n" << endl;
cout << "Let's play! What would you like to do? ";
cin >> decision;
menu(decision);
return 0;
}
void menu(char decision)
{
if (decision == 'T')
{
cout << "THREE WHEEL SLOT MACHINE: FOUR WHEEL SLOT MACHINE: PAYOUT:\n";
cout << "STAR - STAR - STAR STAR - STAR - STAR - STAR 1,000 COINS\n";
cout << "BAR - BAR - BAR BAR - BAR - BAR - BAR 500 COINS\n";
cout << "SEVEN - SEVEN - SEVEN SEVEN - SEVEN - SEVEN - SEVEN 250 COINS\n";
cout << "BAR - BAR - ANY BAR - BAR - BAR - ANY 100 COINS\n";
cout << "PLUM - PLUM - PLUM PLUM - PLUM - PLUM - PLUM 75 COINS\n";
cout << "LEMON - LEMON - LEMON LEMON - LEMON - LEMON - LEMON 50 COINS\n";
cout << "CHERRY - CHERRY - ANY CHERRY - CHERRY - ANY - ANY 25 COINS\n";
cout << "CHERRY - ANY - ANY CHERRY - ANY - ANY - ANY 5 COINS\n" << endl;
}
if (decision == '3')
{
three();
}
if (decision == 'P')
{
if (credits > 0)
{
cout << "You've cashed out " << credits << "!" << endl;
credits = 0;
}
menu(decision);
}
}
void three()
{
int j = 0;
cout << "Enter your bet (CTRL + C to quit): ";
cin >> bet;
for (int i = 0; i < 3; i++)
{
(j = (rand() % 6) + 1);
}
if (chr1 == "STAR" && chr2 == "STAR" && chr3 == "STAR")
{
cout << "JACKPOT!\n";
winnings = bet * 1000;
}
cout << "You won " << winnings << endl;
cout << "Enter your bet (CTRL + C to quit): ";
cin >> bet;
if (chr1 == "BAR" && chr2 == "BAR" && chr3 == "BAR")
{
cout << "BAR x3\n";
winnings = bet * 500;
}
cout << "You won " << winnings << endl;
cout << "Enter your bet (CTRL + C to quit): ";
cin >> bet;
if (chr1 == "SEVEN" && chr2 == "SEVEN" && chr3 == "SEVEN")
{
cout << "SEVEN x3\n";
winnings = bet * 250;
}
cout << "You won " << winnings << endl;
cout << "Enter your bet (CTRL + C to quit): ";
cin >> bet;
if (chr1 == "BAR" && chr2 == "BAR" && chr3 == "ANY")
{
cout << "BAR x2\n";
winnings = bet * 100;
}
cout << "You won " << winnings << endl;
cout << "Enter your bet (CTRL + C to quit): ";
cin >> bet;
if (chr1 == "PLUM" && chr2 == "PLUM" && chr3 == "PLUM")
{
cout << "PLUM x3\n";
winnings = bet * 75;
}
cout << "You won " << winnings << endl;
cout << "Enter your bet (CTRL + C to quit): ";
cin >> bet;
if (chr1 == "LEMON" && chr2 == "LEMON" && chr3 == "LEMON")
{
cout << "LEMON x3\n";
winnings = bet * 50;
}
cout << "You won " << winnings << endl;
cout << "Enter your bet (CTRL + C to quit): ";
cin >> bet;
if (chr1 == "CHERRY" && chr2 == "CHERRY" && chr3 == "ANY")
{
cout << "CHERRY x2\n";
winnings = bet * 25;
}
cout << "You won " << winnings << endl;
cout << "Enter your bet (CTRL + C to quit): ";
cin >> bet;
if (chr1 == "CHERRY" && chr2 == "ANY" && chr3 == "ANY")
{
cout << "Very nice!";
winnings = bet * 5;
}
cout << "You won " << winnings << endl;
}