快速的問題。我想知道如何做到這一點,以便它只會在用戶輸入2-23的數字時運行。調理字符串
BufferedReader in;
int x;
String playerx;
//user input for number of players
in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("\nWelcome to the Casino!");
System.out.println("How many players are playing? (2-23)");
//string for number of players
playerx = in.readLine();
//convert players to integer
x = Integer.valueOf(playerx).intValue();
//condition player x so that the number of players are between 2 and 23
if(playerx.compareTo("1")==0 && playerx.compareTo("24")==0) {
System.out.println("\nSorry, there are either not enough players or not enough cards for that option.");
}else {
是的,這工作非常感謝你! –
我有點空白......「||」的意思是「或」對嗎? –
是的,這是OR條件 – upog