Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes style, linking, adding, swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "style, linking, adding, swing" Watch "style, linking, adding, swing" New topic
Author

style, linking, adding, swing

tom brownlee
Greenhorn

Joined: Aug 14, 2001
Posts: 28
hi everyone...long problem
as a beginner java student we were asked to create a game that involved an algorithm. simple right??? here's the problem
im going to create the oldest game ever.( yes rehashing)
it involves numbers within a form of which there are many forms.
The game is to pick a number (say between 1 and 31). By looking through the forms and by clicking yes when that number appears the programme will display the number at the end of the last form. hence, end of game.
this game (if not worked out already) is based upon the binary theory ie: 2*0(2 to the power of zero), 2*1, 2*2, 2*4 etc.
hence the forms created will have the numbers in them that will make up that number
hence 19 = 2*0( =1) and 2*1( =2) and 2*4( =16) so for numbers between 1 and 31 there will be a max of 5 forms and 19 will be on the 1st, 2nd and 5th form.(2*0 + 2*1 + 2*4)
the programme will know the number 19 because it will look at the first number on the form. hence, either the number 1,2,4,8 or 16. It will then add these numbers up that has the number chosen on that particular form, in this case number 19 ( forms 1,2 and 5) and come to the answer(19 in this case).
it will display the number and ask for a new game.
is it making sense???
the Problem...ive been at it for weeks trying to create a form that works (a template to use for the rest) and also trying to figure out code to link the forms( when the user clicks "no" or "yes" the next form is displayed) and also how the programme will add the numbers to display the number the user has thought of.
can anybody please help...im down to the bear knuckle trying to figure out code and how to start...please remember i am only a beginner and it may sound easy to some...also ive already handed in the documented report of what im going to do so i can't change the game...the only real restriction is that the layout must be created with swing.
...yes im truly stuck and in need of dire help.
sample code (and why that particular code comments) would be most appreciated. thanks guys
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
read about the observer pattern:
http://www.artima.com/designtechniques/eventgen.html
chantal
tom brownlee
Greenhorn

Joined: Aug 14, 2001
Posts: 28
Originally posted by Chantal Ackermann:
read about the observer pattern:
http://www.artima.com/designtechniques/eventgen.html
chantal

thanks chantal..ill give it a read and a go and get back to you
thanks again
tom
tom brownlee
Greenhorn

Joined: Aug 14, 2001
Posts: 28
hi guys , hi chantal
well i read through the link you sent through chantal but im still confused. It explains some of my queries but not a good starting point nor any relevant sample code. I could understand some of his at the link but i couldn't fit it to my own problem
is there anything else i could get from you guys
thankyou for your help so far by the way it'd good to know someones there to hear my problem
thanks guys
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: style, linking, adding, swing
 
Similar Threads
Java Assignment
Beginner Yahtzee Progam
Help with some Math please
Plain help
Abundant Numbers