Gracias por sus respuestas.
La idea del programa es que cuando el jugador entre la opcion 1, 2, o 3 esta sea como una variable (si puedo decir eso) y no como un string. Todavia no se como usar botones o esas cosas avanzadas; razon por la cual tengo que hacerlo con numeros.
Intente poner el int var;, pero me sale un error:
rockpaperscissors1.java:40:cannot find the symbol
symbol method showMessageDialog(java.lang.String)
location: class javax.swing.JOptionPane
selection = JOptionPane.showMessageDialog("Welcome to the Rock, Paper, Scissors"
1 error
No estoy seguro si esto se refiere al hecho de que estoy mezclando variables o algo asi, pero no encuentro la forma de hacer la entrada unicamente con numeros sin utilizar el String.
Cualquier ayuda se las agradezco mucho
Código:
* calling libraries*/
import javax.swing.JOptionPane;
import java.util.Random;
/* Declaring the class */
public class RockPaperScissors1
{
/* Defining The method */
public static void main(String[ ] args)
{
/* Declaring variables*/
int var;
double selection;
double R = 1;
double P = 2;
double S = 3;
Random pc = new Random();
int pcint = pc.nextInt(3)+1;
/* Asking for input from the player and converting the entry into an Integer */
selection = JOptionPane.showMessageDialog("Welcome to the Rock, Paper,
Scissors"
+ "\nEnter 1 for ROCK" + "\nEnter 2 for PAPER" + "\nEnter 3 for SCISSORS");
var = (int) selection;
/* Comparing the two inputs and getting a result */
if(selection == pcint)
JOptionPane.showMessageDialog(null, " It's a Tie! ");
if(selection == 1 && pcint == 2)
JOptionPane.showMessageDialog(null, " PC wins! ");
if(selection == 2 && pcint ==1)
JOptionPane.showMessageDialog(null, " You Win! ");
if(selection == 1 && pcint == 3)
JOptionPane.showMessageDialog(null, " PC Wins! ");
if(selection == 3 && pcint == 1)
JOptionPane.showMessageDialog(null, " You Win! ");
if(selection == 2 && pcint == 3)
JOptionPane.showMessageDialog(null, " PC Wins! ");
if(selection == 3 && pcint == 2)
JOptionPane.showMessageDialog(null, " You Win! ");
/* Program finishes here */
System.exit(0);
}
}