import java.util.Scanner;
public class HELLO {
public static void main(String[] args) {
System.out.println("please input:");
System.out.println("1:ROCK");
System.out.println("2:SCISSORS");
System.out.println("3:PAPER");
boolean flag=true;
while(flag){
int choice=0;
Scanner scanner= new Scanner(System.in);
System.out.println("your choice");
choice=scanner.nextInt();
if( !(choice>0 && choice <4) ){
System.out.println("error input!!!");
continue;
}
int a=(int)(Math.random()*3);
int random=1+a;
switch(choice)
{
case 1:
if(random>2)
System.out.println("you fail");
break;
else if(random == 1){
System.out.println("draw, play it again!");
else{
System.out.println("you win!!!!");
case 2:
if(random==1){
else if(random==2){
case 3:{
if(random==3){
System.out.println("you win!!");
if(choice>0 && choice<4){
switch(random)
case 1 :System.out.println("your competitor is "+random+" :ROCK.");break;
case 2 :System.out.println("your competitor is "+random+" :SCISSORS.");break;
case 3 :System.out.println("your competitor is "+random+" :PAPEFR.");break;
Sign in to make a reply
辣椒酱油都是酱
import java.util.Scanner;
public class HELLO {
public static void main(String[] args) {
System.out.println("please input:");
System.out.println("1:ROCK");
System.out.println("2:SCISSORS");
System.out.println("3:PAPER");
boolean flag=true;
while(flag){
int choice=0;
Scanner scanner= new Scanner(System.in);
System.out.println("your choice");
choice=scanner.nextInt();
if( !(choice>0 && choice <4) ){
System.out.println("error input!!!");
continue;
}
int a=(int)(Math.random()*3);
int random=1+a;
switch(choice)
{
case 1:
{
if(random>2)
{
System.out.println("you fail");
break;
}
else if(random == 1){
System.out.println("draw, play it again!");
break;
}
else{
System.out.println("you win!!!!");
break;
}
}
case 2:
{
if(random==1){
System.out.println("you fail");
break;
}
else if(random==2){
System.out.println("draw, play it again!");
break;
}
else{
System.out.println("you win!!!!");
break;
}
}
case 3:{
if(random==3){
System.out.println("draw, play it again!");
break;
}
else if(random==2){
System.out.println("you fail");
break;
}
else{
System.out.println("you win!!");
break;
}
}
}
if(choice>0 && choice<4){
switch(random)
{
case 1 :System.out.println("your competitor is "+random+" :ROCK.");break;
case 2 :System.out.println("your competitor is "+random+" :SCISSORS.");break;
case 3 :System.out.println("your competitor is "+random+" :PAPEFR.");break;
}
}
}
}
}