I´m really new to java and GUI´s but I´m trying to implement the "guess the number game" to an app. I want to change the max and min variables here n = Integer.parseInt(JOptionPane.showInputDialog ("Choose a number between [%d,%d]:"), min, max); to make the game easier. Obviously this doesn´t work, but it´s the end goal. Any advice? Thanks
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class guessTheNumber {
public static void main(String[] args) {
int nAttempts= 0, min = 0, max = 100;
int n = 0, nRandom = (int)( Math.random() * (( max - min ) + 1 )) + min;
do
{
nAttempts++;
n = Integer.parseInt(JOptionPane.showInputDialog ("Choose a number between [%d,%d]:"), min, max);
if ( n != nRandom)
{
if( n > nRandom )
{
JTextField.
JOptionPane.showMessageDialog(null, "Too High","Wrong Number", JOptionPane.INFORMATION_MESSAGE);
}
if( n < nRandom )
{
JOptionPane.showMessageDialog(null, "Too Low","Wrong Number", JOptionPane.INFORMATION_MESSAGE);
}
}
} while ( n != nRandom);
JOptionPane.showMessageDialog(null, "Congrats!! Attempts = "+ nAttempts,"Level finished", JOptionPane.WARNING_MESSAGE);
}
}