jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes genrating lotto with apllet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "genrating lotto with apllet" Watch "genrating lotto with apllet" New topic

genrating lotto with apllet

Alan Green

Joined: Sep 07, 2003
Posts: 17
am doing homework trying to write a lotto program Writting a JAVA applet simulating a really dedicated lotto player. The applet will have 6 text fields for the player to enter 6 different integers in the range 1 to 53. There will be a button captioned Play. When the player clicks the button, a years worth of playing the lotto with those numbers is simulated. The program generates 104 sets (twice a week for 52 weeks) of 6 unique integers in the range 1 to 53. The player wins some money if a set of 6 numbers matches 3, 4, 5, or all 6 of his numbers. Each play (2 a week) costs $1. The payoffs are: match 3 , $5. match 4: $65, match 5 $1500, match all 6, $7,000,000! Your applet will have a non-editable text field in which the total winnings for the 104 plays will be displayed, and another non-editable text field that will show the cost of the plays. After the 104 plays have been tallied, the player will have the choice of continuing for another "year" with the same numbers (totals accumulating), by clicking the Play button again, or clicking another button captioned Reset, which clears all the text fields and totals and moves the focus to the first text field for the user to enter new numbers. When the play button is clicked after numbers have been entered, the program should validate the users entries and display an error message on a messageDialog if there are any numbers not in the range 1 to 53, or if there are any duplicate numbers. I am having trouble with my action command. I am trying to use get.Source to activate the generation of the numbers when i hit play. Is there an easy way of doing this. Thanx..
Carlos Failde
Ranch Hand

Joined: Oct 20, 2000
Posts: 84
You need to register an event listener with the play button. Event Handling will tell you how.
You may want to use the getActionCommand()
to check if the play button was pressed, but getSource() is still a valid means.
Anyway, you have made a good start to the exercise, keep it up!
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / JFC / AWT forum...
I agree. Here's the link: http://aspose.com/file-tools
subject: genrating lotto with apllet
It's not a secret anymore!