Я пытаюсь использовать данные, которые я видел из другого поста Создание консольного меню для пользователя, чтобы сделать выбор , чтобы создать меню, в котором пользователь выбирает опцию. Когда я запускаю свою программу, она выдает несколько ошибок. Может быть, я не импортирую это правильно, но это единственный метод, который я могу придумать.
import java.util.Random;
import java.util.Data;
public class Main{
public static void main(String[] args) {
System.out.println("Please enter 1 if you'd like to guess the computer's number or enter 2 to have the computer guess your number. If 2, please enter a number between 1-100 after you enter 2. ");
Data data = new Data();
data.menu();
Scanner scanner = new Scanner(System.in);
int choice = scanner.nextInt();
switch (choice) {
case 1:
double r = (Math.random()*((100-1)+1))+min;
int win = 0;
while (win != 1);
System.out.println("The computer has guessed a number, please make a guess. ");
int u1 = scanner.nextInt();
if (r > u1)
System.out.println("Too low.");
else if (r < u1)
System.out.println("Too high.");
else if (r == u1){
System.out.println("You guessed it!!!!!!! Congratulations!!!!!!!!!!");
int win = win + 1 ;}
else
System.out.println();
break;
case 2:
System.out.println("You'd like myself, the computer to guess huh, well be prepared to get destroyed!");
int un = scanner.nextInt();
if (un == 36){
System.out.println("Chandler I told you not to!!!!!!");
break;}
else
System.out.println();
System.out.println("Your number is " + un);
break;
default:
System.out.println("You weren't supposed to do that!!!! Stop the program and run it again. Congrats! You broke it! Chandler, if you entered 36, ");
TimeUnit.SECONDS.sleep(5);
System.out.print("you've been banned!");
}
}
}