/*
* 创建一个类Game石头剪刀布的游戏
*/
public class Game {
/**
* @param args
*/
String[] s ={石头剪刀布};
//获取电脑出拳
String getComputer(int i)
{
String computerGuess = s[i];
return computerGuess;
}
//判断人出拳是否为石头剪刀布
boolean isOrder(String guess)
{
boolean b = false;
for(int x = ;x < slength; x++)
{
if(guessequals(s[x]))
{
b = true;
break;
}
}
return b;
}
//比较
void winOrLose(String guessString guess)
{
if(guessequals(guess))
{
Systemoutprintln(你出 + guess + 电脑出 + guess + 平了);
}else if(guessequals(石头))
{
if(guessequals(剪刀))
{
Systemoutprintln(你出 + guess + 电脑出 + guess + You Win!);
}else
{
Systemoutprintln(你出 + guess + 电脑出 + guess + You Lose!);
}
}else if(guessequals(剪刀))
{
if(guessequals(布))
{
Systemoutprintln(你出 + guess + 电脑出 + guess + You Win!);
}else
{
Systemoutprintln(你出 + guess + 电脑出 + guess + You Lose!);
}
}else if(guessequals(布))
{
if(guessequals(石头))
{
Systemoutprintln(你出 + guess + 电脑出 + guess + You Win!);
}else
{
Systemoutprintln(你出 + guess + 电脑出 + guess + You Lose!);
}
}
}
public static void main(String[] args) {
Game my = new Game();
Game computer = new Game();
Game game = new Game();
String myGuess = javaxswingJOptionPaneshowInputDialog(输入石头剪刀布);
String computerGuess = computergetComputer((int)(Mathfloor(Mathrandom()*)));
if(myisOrder(myGuess))
{
gamewinOrLose(myGuess computerGuess);
}else
{
Systemoutprintln(你输入的不是石头剪刀布!);
}
}
}