Scissors Mini Games
Import java.util.*; Importing packages
public class Game {
public static void Main (String[]args) {
Scanner in = new Scanner (system.in); Import Scanner
System.out.println ("-----------------Scissors Game-------------------");
SYSTEM.OUT.PRINTLN ("Please punch (1. Scissors 2. Stone 3. Cloth)");
int Ren=in.nextint (); The value we enter is Ren.
int computer= (int) (Math.random ()) +1; The computer randomly obtains the value to be computer
String kang= "cloth"; This is a mark I made.
String kang2= "cloth"; It's a marker for a computer.
Switch (ren) {
Case 1:
Kang= "Scissors";
Break
Case 2:
Kang= "Stone";
Break
Case 3:
kang= "cloth";
Break
}
Switch (computer) {
Case 1:
Kang2= "Scissors";
Break
Case 2:
Kang2= "Stone";
Break
Case 3:
kang2= "cloth";
Break
}
if (ren==computer) {
System.out.println ("Draw");
}else if (ren==1 && computer==2) {
System.out.println ("You lose #-_-you out is" +kang+ "computer Out is" +kang2 ");
}else if (ren==2 && computer==3) {
System.out.println ("You lose #-_-you out is" +kang+ "computer Out is" +kang2 ");
}else {
System.out.println ("You win ^-^" + "You Out is" +kang + "computer Out is" +kang2);
}
System.out.println ("-----------------Scissors Game-------------------");
}
}
No.21 Java Scissors Applet