日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java esp_在我的ESP游戏方法中非法开始表达

發(fā)布時間:2024/9/19 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java esp_在我的ESP游戏方法中非法开始表达 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

公共靜態(tài)字符串guessColor(掃描儀鍵盤)是我的錯誤所在 . 錯誤如下:非法開始表達(dá):公開,靜態(tài) . 錯誤:';'預(yù)期:在String和guessColor之間 . 錯誤';'預(yù)期:在掃描儀和鍵盤之間 . 非法開始表達(dá):at)在那一行 .

public class RichardsonESPGame

{

public static void main(String[] args)

{

String random;

String guess;

Scanner keyboard = new Scanner(System.in);

random = computerColor();

guess = guessColor(keyboard);

String end = recordGame(random, guess);

System.out.println(end);

keyboard.close();

}

/**

In this method the color choices will be displayed.

*/

public static String computerColor()

{

Random rand = new Random();

int color = rand.nextInt(5) + 1;

return receiveColor(color);

}

/**

This method will give the computer and user its color options.

*/

public static String receiveColor(int color)

{

String selection;

switch (color)

{

case 1:

selection = "Red";

break;

case 2:

selection = "Blue";

break;

case 3:

selection = "Green";

break;

case 4:

selection = "Yellow";

break;

case 5:

selection = "Orange";

break;

default:

System.out.println("Make a valid selection.");

selection = null;

}

return selection;

/**

This method will get the user's color choice.

*/

public static String guessColor(Scanner keyboard)

{

System.out.println("Enter a number from 1 to 5 to receive a color.\n 1 is Red\n 2 is Blue\n 3 is Green\n 4 is Yellow\n 5 is Orange\n");

int richardsonGuessColor = keyboard.nextInt();

String color = receiveColor(richardsonGuessColor);

while (color == null)

{

System.out.println("Enter a number from 1 to 5 to receive a color.\n 1 is Red\n 2 is Blue\n 3 is Green\n 4 is Yellow\n 5 is Orange\n");

int guess = keyboard.nextInt();

color = receiveColor(richardsonGuessColor);

}

return color;

}

/**

This method will determine if user guesses correctly.

*/

public static String recordGame(String richardsonComputerColor, String richardsonGuessColor)

{

String end;

end = "The computer's choice was: " + richardsonComputerColor;

end += "Your choice was: " + richardsonGuessColor;

if(richardsonGuessColor.equalsIgnoreCase("Red"))

{

if (richardsonComputerColor.equalsIgnoreCase("Red"))

{

end += "You guessed correctly!";

}

else

{

result += "You guessed incorrectly.";

}

}

else if(richardsonGuessColor.equalsIgnoreCase("Blue"))

{

if (richardsonComputerColor.equalsIgnoreCase("Blue"))

{

end += "You guessed correctly!";

}

else

{

result += "You guessed incorrectly.";

}

}

else if(richardsonGuessColor.equalsIgnoreCase("Green"))

{

if (richardsonComputerColor.equalsIgnoreCase("Green"))

{

end += "You guessed correctly!";

}

else

{

result += "You guessed incorrectly.";

}

}

else if(richardsonGuessColor.equalsIgnoreCase("Yellow"))

{

if (richardsonComputerColor.equalsIgnoreCase("Yellow"))

{

end += "You guessed correctly!";

}

else

{

result += "You guessed incorrectly.";

}

}

else if(richardsonGuessColor.equalsIgnoreCase("Orange"))

{

if (richardsonComputerColor.equalsIgnoreCase("Orange"))

{

end += "You guessed correctly!";

}

else

{

result += "You guessed incorrectly.";

}

}

return end;

}

}

總結(jié)

以上是生活随笔為你收集整理的java esp_在我的ESP游戏方法中非法开始表达的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。