Slot Machine Problem
Hey there! I have begun to write a slot machine program/game. I have got it to work and the code looks like this:
Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
srand(time(0));
int again;
int number1 = rand() % 3 + 1;
int number2 = rand() % 3 + 1;
int number3 = rand() % 3 + 1;
cout << number1 << number2 << number3 << '\n' << endl;
if (number1 != 3 || number2 != 3 || number3 != 2)
{
cout << "You lose!\n";
cout << "Try Again?\n";
cin >> again;
}
else
{
cout << "You won!\n";
}
if (again == 1)
{
cout << main();
}
if (again == 2)
{
EXIT_SUCCESS;
}
}
But the problem is that I don't know how to have more than 1 number that's correct. Right now have I the number 332 but I want more numbers that's correct. At least 3 numbers. I tried to code the same lines but with another numbers in it but that didn't worked. Also coded I this line once more with another number:
Code:
if (number1 != 2 || number2 != 3 || number3 != 3)
{
cout << "You lose!\n";
cout << "Try Again?\n";
cin >> again;
}
else
{
cout << "You won!\n";
}
Please can someone tell me how to do that?.