Make a "slot machine" game that randomly displays the results of a slot machine to a player—have 3
(or more) possible values for each wheel of the slot machine. Don't worry about displaying the text
"spinning" by. Just choose the results and display them and print out the winnings (choose your own
winning combinations).
#include <cstdlib>
#include <ctime>
#include <iostream>
usingnamespace std;
int randRange(int high, int low);
int main()
{
srand(time(NULL));
int random_num = randRange(10, 1); // first_ random number
int random_num1 = randRange(10, 1); // second random number
cout << "Please Enter to run the slot machine" << endl;
cin.get();
if(random_num == random_num1)
{
cout << "The Numbers are " << random_num << " and " << random_num1 << ", you win" << endl;
}
else
{
cout << "The Numbers are " << random_num << " and " << random_num1 << ", you loose" << endl;
}
}
int randRange(int high, int low)
{
return rand() % (high - low) + low;
}
Is it good enough for a slot machine?
Please Share Your methods also , How will you make Slot Machine?
If was doing it with graphics, I definitely use a game engine. If I was doing it in the console, I'd do it with <string> using 3 string arrays holding each fruit.
1 2 3 4
string slot1[10], slot2[10], slot3[10];
//Then fill the slots
//Then generate random mixes of them.
//Then check if 3 are lined up and give the appropriate prize (i.e. the same fruit was chosen on all 3).