Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,412 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,456 people online right now. Registration is fast and FREE... Join Now!




need help thinking of which fucntions to use...

 
Reply to this topicStart new topic

need help thinking of which fucntions to use..., 3 wheel slot machine

nicoli
15 Oct, 2008 - 07:45 AM
Post #1

New D.I.C Head
*

Joined: 8 Oct, 2008
Posts: 3

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;
}














User is offlineProfile CardPM
+Quote Post

RedSonja
RE: Need Help Thinking Of Which Fucntions To Use...
16 Oct, 2008 - 03:43 AM
Post #2

D.I.C Head
Group Icon

Joined: 4 Sep, 2008
Posts: 170



Thanked: 3 times
Dream Kudos: 25
My Contributions
slot1, slot2, slot3 are not defined

bool checkWin(int, int, int); try int i1, int i2, int i3

turn all those ifs into if elses or use switch



Now give it another try. The compiler will usually tell you quite clearly what the problem is.

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 12:28PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month