Skip to content

Instantly share code, notes, and snippets.

@takuma7
Created December 16, 2011 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuma7/1484159 to your computer and use it in GitHub Desktop.
Save takuma7/1484159 to your computer and use it in GitHub Desktop.
import java.util.Random;
import java.io.*;
class Mondai19_3{
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
boolean undone=true;
Random rand=new Random();
while(undone){
int my=0;
do{
System.out.print("yours> ");
my = Integer.parseInt(br.readLine());
}while(my<1 || 3<my);
int cmp=rand.nextInt(3)+1;
System.out.println("cmp's> " + cmp);
if(my==cmp){
System.out.println("Draw!");
}else{
boolean win=true;
if(my==1 && cmp==3){
win=false;
}else if(my==2 && cmp==1){
win=false;
}else if(my==3 && cmp==2){
win=false;
}
if(win){
System.out.println("You win!");
}else{
System.out.println("You lose!");
}
undone=false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment