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

Recommended Answers

All 10 Replies

dito

the most common way to pass values between objects is to simply create getter methods. we can be of more help if you give more specific issues, otherwise it just sounds like you want us to do you assignment for you.

wud be nice <3

you've got it easy, all you need to do is watch your classmate get the answers and use them yourself. a heart isn't enough to make me want to do that assignment either :)

wud be nice <3

No it wouldn't.

You might think would be, but how would that help you on your next assignment, which is meant to build on what you learned in this assignment? If someone does it for you, you haven't learned anything (and don't give me the bs that "I'll study the code and try to understand it", because, no, you won't, you'll simply hand it in and that's it) and for the next assignment you'll be even more lost than you are now.

who said i wud bs last assignment just want it out the way enit

who said i wud bs last assignment just want it out the way enit

What you said makes no sense. Please use proper English

That's even worse. So we're to simply earn you a completion you don't deserve so that somebody else (possibly the one giving the answer) then also has to do your work for your ignorant self so you get paid, since you won't know how to do it yourself.

i am pretty sure none of the solution givers are stupid enough to help him out without showing any effort, so i wouldn't worry. if he choses to waste his time monitoring the net instead of attempting this himself, it's his own fault. chillax :)

who said i wud bs last assignment just want it out the way enit

got English out the way too?

have you got some code of yourself you can show us, or are you just freeloading on your classmates?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.