可能であればガイダンスが必要です。 Javaを初め。岩、紙、はさみゲームの下のコードがなぜ機能していないのかわからない。何かアドバイスをお願いしますか、アドバイスが大歓迎です。私はこの素晴らしいフォーラムに多くの例があることを知っています - しかし、私はまだ基本を掴んでいます。ありがとうございました。Javaプログラミング - ペーパーロッカー用はさみ
import java.util.*;
import java.util.Scanner;
import java.util.Random;
public class Game
{
public static void main (String[] args){
int NumberofRoundsPlayed;
int NumberofRoundsWonbyHuman = 0;
Scanner Keyboard = new Scanner (System.in
System.out.println("DO YOU WANT TO PLAY ROCK PAPER SCISSORS- Y/N");
String HumanPlaying = Keyboard.nextLine();
if(HumanPlaying ==("No"))
{
System.out.println("Game Over");
System.exit(0);}
}
int Paper = 1;
int Scissor = 2;
int Rock = 3;
int HumanSelection;
int humanroundsWon =0;
System.out.println("HOW MANY ROUNDS DO YOU WANT TO PLAY");
NumberofRoundsPlayed = Keyboard.nextInt();
while (NumberofRoundsPlayed <= NumberofRoundsPlayed +1)
{
Scanner Computer = new Scanner (System.in);
Random rand = new Random();
int ComputerChoice =Computer.nextInt(3)+1;
System.out.println(ComputerChoice);
System.out.println("Select 1 for Paper, 2 for Scissor or 3 for Rock");
HumanSelection = Keyboard.nextInt();
//SEE WHO WINS
If (ComputerChoice== 1)
{
If (HumanSelection==1)
{
System.out.println("Computer and Human Have Tied");
} Else if (HumanSelection==2)
{
System.out.println("Person Wins");
humanroundsWon == humanroundsWon+1;
}
Else if (HumanSelection==3)
{
System.out.println("Computer Wins");
}
Else if (ComputerChoice==2)
{
If (HumanSelection==1)
{
System.out.println("computer Wins");
}
Else if (HumanSelection==2)
{
System.out.println("Computer and Person Have Tied");
}
Else if (HumanSelection==3)
{
System.out.println("Person Wins");
humanroundsWon == humanroundsWon+1;
}
}
Else if (ComputerChoice==3)
{
}
If (HumanSelection==1)
{
System.out.println("Person Wins");
humanroundsWon == humanroundsWon+1;
}
Else if (HumanSelection==2)
{
{ System.out.println("Computer Wins");
}
Else if (HumanSelection==)
{
System.out.println("Tie");
roundsWon == roundsone+1;
}
}
}
}
}
}
System.out.println("Game Over");
System.exit(0);}
どのように動作しませんか? – elhefe
'humanroundsWon == humanroundsWon + 1;'おそらく 'humanroundsWon = humanroundsWon + 1;'でなければなりません。または 'humanroundsWon + = 1;'。または 'humanroundsWon ++;' –
おかげさまでelhefe。主にプログラムの主要部分が始まるときに文法エラーがたくさん出る - コンピュータが「人間」と一緒に乱数を選択した後、 - この行に複数のマーカーがある \t - トークンに構文エラーがある \tこのトークン \t - トークンの構文エラー、置き換えられた構文 \t - このトークンの後には、 "{"が必要です。私はこの段階で基礎を理解することに問題があります。だから私はこのエラーコードをどうすればいいのか分かりません。 – Chris