hi there i need to make a program that the user using comboboxes chooses the number of guesses and and range of guesses they are allowed using a GUI that looks like this:
http://smg.photobucket.com/albums/v321/How...nt=Untitled.jpg
i have made all the buttons etc and for the range combobox have used the code:
private void NumberRangeItemStateChanged(java.awt.event.ItemEvent evt) {
int RangeChange;
RangeChange = NumberRange.getSelectedIndex();
if (RangeChange <= 1) {
RangeChange = 6;
} else if (RangeChange == 2) {
RangeChange = 9;
} else {
RangeChange = 40;
}
}
the ranges are either a number between 1-6, 1-9 or 1-40 and default = 1-6.
for the number of guesses code i have used:
private void NumberOfGuessesItemStateChanged(java.awt.event.ItemEvent evt) {
int guessChange;
guessChange = NumberOfGuesses.getSelectedIndex();
if (guessChange <= 1) {
guessChange = 1;
} else if (guessChange == 2) {
guessChange = 4;
} else {
guessChange = 7;
}
}
i hope i have done this right but im not sure how i would bring the information from these comboboxes into another class (MainGame.java)
and also the user types the number they are guessing into a JTextField and it needs to say if the number (the program has randomly allocated) using
import java.util.Random; // an import statement to access the class Random
Random random = new Random(); //create an instance of Random
random.nextInt(7); // returns an int random number between 1 and 6.
is higher or lower than the number the user has put in.
and when the number of guesses = 0 then to say something like "sorry the number=X"
im not really that good at java and not sure how to do any of this, any advice or pointers will be greatlly appreciated