Created
December 16, 2011 02:31
-
-
Save takuma7/1484159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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