Vous êtes sur la page 1sur 7

Simple Slot Machine Game

A person playing a slot machine purchases the right to play by inserting coins, cash, or in newer Ticket-In, Ticket-Out machines, a paper ticket with a barcode, into a designated slot on the machine. The machine is then activated by means of a lever or button, or on newer machines, by pressing a touchscreen on its face. The game itself may or may not involve skill on the player's part or it may create the illusion of involving skill while only being a game of chance. The object of the game is to win money from the machine. The game usually involves matching symbols, either on mechanical reels that spin and stop to reveal one or several symbols, or on simulated reels shown on a video screen. The symbols are usually brightly colored and easily recognizable, such as images of fruits, numerals or letters, and simple shapes such as bells, diamonds, or hearts; newer video slot machines use animated cartoon characters and images of popular actors or singers . Most games have a variety of winning combination of symbols, often posted on the face of the machine. If a player matches a combination according to the rules of the game, the slot machine pays the player cash or some other sort of value, such as extra games. This program or application is a simple slot machine game instead of icons like cherries or other icons or fruits usually used in a slot machine, numbers were used in this program to be randomized and will be the basis if the player will win. . If the player got a pattern of 7 7 7, his winnings will be the bet multiplied to 10 and if he got three the same number in the pattern except 7 7 7 his winnings will be the bet multiplied by 5 and lastly if he got two the same number in the patter his winnings will be the bet multiplied by 3 else he loses. He could also exit the game anytime.

User Manual:
If the program is run, the program will output name of the game which is My Simple Slot Machine Game and will also show the amount of chips the user have which the initial amount is $1500. The program will give 2 choices to the user and this is if he want to play or he wants to exit the program. In order to choose the user must input 1 to play and 2 to exit. If the user inputted 2 then the program will be terminated but if not the program will ask the player to input his bet. If the bet inputted is greater than the maximum amount the program would tell the user that his bet is invalid. If the inputted amount is less than or equal to the amount, then the program will randomize three numbers. If the numbers are all seven then the winner won the bet multiplied by 10, if he got three the same number in the pattern except 7 7 7 his winnings will be the bet multiplied by 5 and lastly if he got two the same number in the patter his winnings will be the bet multiplied by 3 else he loses. The whole game, the user may exit if he don't want to play anymore by entering '2'.

Source Code:
//////////////////////////////////////Aubrey Camille C. Cabrera//////////////////////////////// //////////////////////////////////////////////CS10-L-A1916//////////////////////////////////////////// ///////////////////////////////////////---Simple Slot Machine Game---//////////////////////////// #include<iostream> // iostream library is an object-oriented library that provides input and output functionality using streams #include<string> //class template specifically designed to manipulate strings of characters of any character type #include<cstdlib> //defines several general purpose functions, including dynamic memory management, random number generation, communication with the environment, integer arthmetics, searching, sorting and converting. #include<ctime> //contains definitions of functions to get and manipulate date and time information using namespace std; int main() //data type { float amount=1500,bet; //initialize variales into float data type and assigned 1500 as the value of amount int choice,ran1,ran2,ran3; //initialize the variables into integer data type srand(time(0)); //initialize random seed cout<<"My Simple Slot Machine GAME"<<endl; //prints My Simple Slot Machine GAME while(true) //flag -controlled while loop { cout<<"our Chips = $"<<amount<<endl; //print in the screen Our chips=$1500 cout<<"1. Play Slot"<<endl<<"2. Exit"<<endl;//print in the screen 1. Play slot 2. Exit cout<<"Your Choice:"; //ouputs "Your Choice:" cin>>choice; // lets the user to input a choice between 1 and 2 if(choice==1) //if the user choose 1 statements inside the if will run { cout<<"Place Your Bet:"; // print Place Your Bet cin>>bet; // inputs the bet if(bet>amount) // if the bet is greater the amount statements inside the if will run { cout<<"Invalid bet. Place a valid bet."; // outputs Invalid bet. Place a valid bet

continue; } else // if bet is greater than the amount is false statements inside else will be executed { ran1=3+rand()%5; // this will be the first number ran2=3+rand()%5; //second number of the pattern ran3=3+rand()%5; // last number in the pattern } // if the three numbers are all 7 then the new amount will be amountbet+10*bet if(ran1==7 && ran2==7 && ran3==7) { cout<<"You Win!!"<<endl; cout<<ran1<<" "<<ran2<<" "<<ran3<<endl; amount=amount-bet+10*bet; } // if three numbers are the same but not 7 then the new amount will be amount-bet+5*bet else if(ran1==ran2 && ran2==ran3 &&(ran1!=7 && ran2!=7 && ran3!=7)) { cout<<"You Win!!"<<endl; cout<<ran1<<" "<<ran2<<" "<<ran3<<endl; amount=amount-bet+5*bet; } // if there are two same numbers in the number the player still win and the new amount would be amount-bet+3*bet else if(ran1==ran2 || ran2==ran3 || ran3==ran1) { cout<<"You Win!!"<<endl; cout<<ran1<<" "<<ran2<<" "<<ran3<<endl; amount=amount-bet+3*bet; } // but if not the player lose and his bet will be dueducted to his amount else { cout<<"You Lose!!"<<endl; cout<<ran1<<" "<<ran2<<" "<<ran3<<endl; amount=amount-bet; if(amount==0) { cout<<"Thanks for playing."<<endl<<"Exiting"<<endl; break; } } }

if the choice between 1 and 2 is 2 the program will be terminated else if(choice==2) { cout<<"Thanks for playing."<<endl<<"Exiting"<<endl; break; } else { cout<<"Invalid Choice. Exiting."<<endl; system("pause"); break; } } }

Vous aimerez peut-être aussi