import java.util.*;
import javax.swing.*;public class game1
{
public static void main(String[] args)
{ //Comment on what variable are
int Userinput, ComputerChoice, result;
int rock = 0;
String Userinput_str;
Userinput_str = JOptionPane.showInputDialog("0 = rock\n\n" +
"1 = scissor " + "\n\n" +
"2 = paper" + "\n\n"+"your guess");
Userinput = Integer.parseInt(Userinput_str); Random generator = new Random(); ComputerChoice = generator.nextInt(3); result = Userinput - ComputerChoice; while(Userinput == 0 || Userinput == 1 || Userinput == 2 )
{ if(result == ComputerChoice)
{
System.out.println("Your Choice is as same as ComputerChioce's, Try again");
}
else
{
if(Userinput == 0 && ComputerChoice == 1 && result == -1)
System.out.println("You Win, rock smashes scissor"); if(Userinput == 0 && ComputerChoice == 2 && result == -2)
System.out.println("Computer Win, paper smothers rock"); if(Userinput == 1 && ComputerChoice == 2 && result == -1)
System.out.println(" You Win, scissor cuts paper"); if(Userinput == 1 && ComputerChoice == 0 && result == 1)
System.out.print("Computer Win, rock smashes csissor"); if(Userinput == 2 && ComputerChoice == 1 && result == 1)
System.out.println("Computer Win, scissor cuts paper"); if(Userinput == 2 && ComputerChoice == 0 && result == 2)
System.out.println("You win, paper smothers rock"); }
}
System.exit(0);
}
}
import javax.swing.*;public class game1
{
public static void main(String[] args)
{ //Comment on what variable are
int Userinput, ComputerChoice, result;
int rock = 0;
String Userinput_str;
Userinput_str = JOptionPane.showInputDialog("0 = rock\n\n" +
"1 = scissor " + "\n\n" +
"2 = paper" + "\n\n"+"your guess");
Userinput = Integer.parseInt(Userinput_str); Random generator = new Random(); ComputerChoice = generator.nextInt(3); result = Userinput - ComputerChoice; while(Userinput == 0 || Userinput == 1 || Userinput == 2 )
{ if(result == ComputerChoice)
{
System.out.println("Your Choice is as same as ComputerChioce's, Try again");
}
else
{
if(Userinput == 0 && ComputerChoice == 1 && result == -1)
System.out.println("You Win, rock smashes scissor"); if(Userinput == 0 && ComputerChoice == 2 && result == -2)
System.out.println("Computer Win, paper smothers rock"); if(Userinput == 1 && ComputerChoice == 2 && result == -1)
System.out.println(" You Win, scissor cuts paper"); if(Userinput == 1 && ComputerChoice == 0 && result == 1)
System.out.print("Computer Win, rock smashes csissor"); if(Userinput == 2 && ComputerChoice == 1 && result == 1)
System.out.println("Computer Win, scissor cuts paper"); if(Userinput == 2 && ComputerChoice == 0 && result == 2)
System.out.println("You win, paper smothers rock"); }
}
System.exit(0);
}
}
import javax.swing.*;public class game1{
public static void main(String[] args){ //Comment on what variable are
int Userinput, ComputerChoice, result;
int rock = 0;
String Userinput_str;
Userinput_str = JOptionPane.showInputDialog("0 = rock\n\n" +
"1 = scissor " + "\n\n" +
"2 = paper" + "\n\n"+"your guess");
Userinput = Integer.parseInt(Userinput_str);
Random generator = new Random(); ComputerChoice = generator.nextInt(3); result = Userinput - ComputerChoice;
while(Userinput == 0 || Userinput == 1 || Userinput == 2 ) { if(result == ComputerChoice)
{ System.out.println("Your Choice is as same as ComputerChioce's, Try again");
}
else {
if(Userinput == 0 && ComputerChoice == 1 && result == -1)
System.out.println("You Win, rock smashes scissor");
if(Userinput == 0 && ComputerChoice == 2 && result == -2)
System.out.println("Computer Win, paper smothers rock");
if(Userinput == 1 && ComputerChoice == 2 && result == -1)
System.out.println(" You Win, scissor cuts paper");
if(Userinput == 1 && ComputerChoice == 0 && result == 1)
System.out.print("Computer Win, rock smashes csissor");
if(Userinput == 2 && ComputerChoice == 1 && result == 1)
System.out.println("Computer Win, scissor cuts paper");
if(Userinput == 2 && ComputerChoice == 0 && result == 2)
System.out.println("You win, paper smothers rock");
}
Userinput_str = JOptionPane.showInputDialog("0 = rock\n\n" +
"1 = scissor " + "\n\n" +
"2 = paper" + "\n\n"+"your guess");
Userinput = Integer.parseInt(Userinput_str);
generator = new Random();
ComputerChoice = generator.nextInt(3);
result = Userinput - ComputerChoice;
}
System.exit(0);
}}