• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with Random Numbers plus

 
Cutter Jones
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone.

I'm am new....I am stuck...please help

I'm trying to yes...do an assignment, but can't seem to wrap my head around it for some reason.

The assignment is:
-Create a lottery game application.
-Generate three random numbers from 0-9
-Allow the user to guess three numbers.
-Compare each of the users guesses to the three random numbers and
display a message that includes the users guesses and the randomly generated numbers and the amount of $$ won.
-The applications should accomadate repeating numbers.
(ie. the user guesses 1,2,3 and 1,1,1 comes up..he/she should only get credit for the one "1")

I've been going back and forth with different thoughts on how to proceed, and build on what I have.(if possible).

I'm coming here in hopes there is someone, who can guide me in the right direction.
This is where I am so far.


CODE:






Thank you in advance

Cutter
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would write this as a command line application first, without worrying about the GUI components. Once you have the logic working (your "model"), then you can connect it to a GUI (your "view").

As for the logical model, you already have the problem fairly well defined in English. I would suggest writing each of these "tasks" as a separate Java method. For example, you might write a method generateRandomNumbers(), or getUserInput(), or displayResults()...

I think you'll find it helpful breaking the assignment down into parts like this. Try that, and see how it goes.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags. Unformatted code/config/etc. is difficult to read. You can edit your post to include them using the button or re-post the question with proper formatting.
 
A Mann
Greenhorn
Posts: 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Marc - write a command line application first, and break the task down into manageable chunks (or 'methods').

For overall structure you could maybe try something like this.
(I'm a noob too when it comes to Java, so this is far from perfect, but hopefully helps a little)



Obviously come back and ask again if you get stuck on any of those methods, or anything in this is unclear.

Good Luck
 
Cutter Jones
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you...

Unfortuanatly, we haven't learned "array" yet...I could probably firgure it out, but I don't think that would go over well with my teacher.

I guess my first problem is how do I compare a user input of one 3 digit number to the random 3 one digit numbers...?

There should be a logical way to do this....at least one that a noob like me can understand.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One solution could be, to match the input from a command line app one digit at a time - like this one:
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If anybody wishes to continue discussion about deleting text, please go to a duplicate of this thread here. The posts about deleting text will be removed from this copy of the thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic