私がやろうとしているのは、ToF と呼ばれるゲームとスピンと呼ばれるゲームの 2 つがあるということです。入力文字列が「スピン」の場合、スピンゲームを開始します。コンソール入力を int に変換します。
入力された int が 1 の場合、ホイールをスピンします。入力された int が -1 の場合、コンソール入力を String に変更し、ループから抜け出します。
しかし、私はこのエラーが発生しています:
src\Main.java:39: error: incompatible types
input = console.nextLine();
私のプロパティ:
private static Scanner console = new Scanner(System.in);
private static Spin spin = new Spin();
private static String input = "";
private static String[] gamesArray = new String[] {"spin", "tof"};
private static boolean spinWheel = false;
private static boolean tof = false;
そして、エラーがあります:
while (input.equals("spin")) {
System.out.println("Spin game!");
spinWheel = true;
int input = console.nextInt();
if (spinWheel) {
System.out.println("Welcome to the spin game! Please write 1 to spin. and -1 to exit back");
switch (input) {
case -1:
input = console.nextLine();
break;
case 1:
break;
}
}
}
なにが問題ですか?なぜこれを行うのですか?どうすればこれを修正できますか?