programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

tom brownlee
Greenhorn
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
Posts: 508
http://www.artima.com/designtechniques/eventgen.html
chantal

tom brownlee
Greenhorn
Posts: 28
Originally posted by Chantal Ackermann:
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
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

 It is sorta covered in the JavaRanch Style Guide.