Код: Выделить всё
import java.util.Scanner;
import java.util.Random;
public class Main {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int slots[] = new int[3];
Boolean play = true;
String playAgain;
System.out.println("Welcome to the Simple Slot Machine!");
System.out.println("Press Enter to spin the wheels...");
Reel(slots);
}
public static void Reel(int[] slots) {
Random rand = new Random();
int num1 = 0;
int num2 = 0;
int num3 = 0;
int i;
for( i = 0; i < slots.length; i++) {
slots[i] = rand.nextInt(10);
}
num1 = slots[0];
num2 = slots[1];
num3 = slots[2];
if (num1 == num2 && num2 == num3) {
System.out.print(slots[i] + "... you win");
}
else if (num1 != num2) {
System.out.print(slots[i] + "... you lose");
}
}
}
и я придумал, как прикрепить один из каждых трех элементов к трем переменным
но как только я создаю условие, при котором, если num1 не равно num2, код прерывается
мне нужно сказать 777... ПОБЕДИТЕЛЬ! или 546... НЕУДАЧНИК!
хочу, чтобы это заработало, прежде чем я буду работать над циклом
Подробнее здесь: https://stackoverflow.com/questions/781 ... ot-machine