gpt4 book ai didi

Java 编程 - 石头剪刀布的初学者

转载 作者:行者123 更新时间:2023-12-01 10:05:41 26 4
gpt4 key购买 nike

如果可能的话,需要一些指导。 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);}

最佳答案

如果无法编译,Scanner Keyboard = new Scanner (System.in 是一个不完整的语句。

关于Java 编程 - 石头剪刀布的初学者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36491600/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com