Slot Machine Help please?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Slot Machine Help please?

  1. #1
    Join Date
    Feb 2011
    Posts
    0

    Slot Machine Help please?

    whenever i run this code on devc++ my compiler crashes its just the beginning but can somebody help me along through this?

    code:


    Code:
    /**
     *    @author mgawronski
     *    @version 2/15/11    
     *
     *    Code Description:
     *
     */
    #include <iostream>            //Allows user to interact with application
    #include <stdlib.h>         //used to extract largest int value
    #include <time.h>           //used to extract time from internal clock
    #include <cstdlib>
    #include <conio.h>
    
    using namespace std;        //Introduces namespace std
    
    int Wager;
    int Chips = 1000;
    int Fruit;
    string FruitName;
    string WheelOne;
    string WheelTwo;
    string WheelThree;
    
    void Intro();
    //pre:
    //post:
    void Intro()
    {
        cout<<"*********************************************\n"
            <<"---------------------------------------------\n"
            <<"***********Welcome to DJM's Casino***********\n"
            <<"---------------Enjoy The Slots---------------\n"
            <<"*********************************************\n\n";
    }
    
    void Exit();
    //pre:
    //post:
    void Exit()
    {
        cout<<"*********************************************\n"
            <<"---------------------------------------------\n"
            <<"******Thanks For Visiting DJM's Casino*******\n"
            <<"-----------------Visit Again-----------------\n"
            <<"*********************************************\n\n";
    }
    
    int Bet();
    //pre:
    //post:
    int Bet()
    {
        cout<<"You have $"<<Chips<<endl;
        cout<<"Place your bet (Whole Number): ";
        cin>>Wager;
        Chips = Chips - Wager;
    }
    
    int Win();
    //pre:
    //post:
    int Win()
    {
        
    }
    
    string GetFruit();
    //pre:
    //post:
    string GetFruit()
    { 
            Fruit = (rand()&#37;3)+1;
        
            if(1 == Fruit)
            {
                FruitName = "Cherry";
            }
                else if(2 == Fruit)
                {
                    FruitName = "Orange";
                }
                else if(3 == Fruit)
                {
                    FruitName = "Apple";
                }
            else
            {
               cout<<"How did this happen?";
            }
    }
    
    void Play();
    //pre:
    //post:
    void Play()
    {
        Intro();
        Bet();
    
        cout<<"Press Enter to Begin Slots\n";
        getch();
    
        GetFruit();
        WheelOne = FruitName;
        GetFruit();
        WheelTwo = FruitName;
        GetFruit();
        WheelThree = FruitName;
    
        cout.setf(ios::fixed);
        cout.width(30);
        cout<<WheelOne<<"   "<<WheelTwo<<"   "<<WheelThree<<endl;
    
        Exit();
    }
    
    int main()
    {
        srand(time(NULL));        //initialize random seed
        Play();
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    Last edited by Marc G; February 20th, 2011 at 04:52 AM. Reason: Added code tags

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    Re: Slot Machine Help please?

    Your compiler crashes?
    What do you mean?
    Does it give an error?
    If so, which error?

    Also, you are missing a include for <string>

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center