I'm having trouble thinking of the types of functions I must use for the program below. one fucntion might be slotMachine(int, int, int) or int credits(int). Basically I'm having trounlr starting the program. I'm posting the assignment for anyone to read. Below the assignment I have some code that I wrote- won't compile. Any feedback would be greatly appreciated.
Thanks
//assignment
Write a program to allow the user to play a slot machine. Choose a 'theme' for your machine. For example, many actual slot machines use 'bars', where you try to match three single bars, three double bars, etc. Other machines use 'fruit' as a theme, where the user tries to match three cherries, three oranges, etc.
Include a 'wild' card that counts as anything to help the user win. The game should be somewhat balanced. The user should have a chance of winning to make the game fun. The user should not always win however, as that would not be a challenge. Choose appropriate odds of items showing up to achieve this balance.
Write this program to accept input with just a keystroke and not require the user to press the return key (look up the function’getch’). The screen should look attractive, and the different ways to win should always be visible.
Start the user with 100 credits. Don’t let the user bet money they don’t have. Make sure you include a 'jackpot' where if the user gets three 'wild' cards they win a very nice amount.
The following options should always be available to the user:
1. Insert Credit (Max of three per play)
2. Pull Lever (Must have at least one credit inserted)
3. Quit
//Code I wrote so far
CODE
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;
int slotMachine(int&, int&, int&);
void pullLever();
bool checkWin(int, int, int);
srand(time(0));
int main()
{
int credits=100, bet;
slotMachine(slot1, slot2, slot3)
//do
//{
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"Welcome to Casino Monogahela"<<endl;
cout<<"Press 1,2 or 3 to play 1,2 or 3 credits"<<endl;
cout<<"Press 4 to quit at any time"<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cin>>bet;
while(!(cin >> credits) || cin.peek() != '\n' ||bet<1||bet>3)
{
cout << "Please enter a 1,2 or 3 ";
cin.clear();
cin.ignore(30000, '\n');
}
system("PAUSE");
return 0;
}
int slotMachine(int& slot1, int& slot2, int& slot3);
{
slot1=rand()%4+1;
slot2=rand()%4+1;
slot3=rand()%4+1;
if(slot1==4)
cout<<"wild"<<endl;
if(slot1==3)
cout<<"cherry"<<endl;
if(slot1==2)
cout<<"apple"<<endl;
if(slot1==1)
cout<<"plum"<<endl;
if(slot2==4)
cout<<"wild"<<endl;
if(slot2==3)
cout<<"cherry"<<endl;
if(slot2==2)
cout<<"apple"<<endl;
if(slot2==1)
cout<<"plum"<<endl;
if(slot3==4)
cout<<"wild"<<endl;
if(slot3==3)
cout<<"cherry"<<endl;
if(slot3==2)
cout<<"apple"<<endl;
if(slot3==1)
cout<<"plum"<<endl;
return 0;
}