• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Random Number Generator

 
Tim G
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am starting to learn Java and the current exercise is to create a "guess the number" game in an applet. I've written the code to create the applet and display a label and textfield for the user to input a guess. The number is to be gnereated by math.random and shoud be between 1 and 1000. Once a user enters a number and hits the enter key, the applet should display too high, too low, or correct depending upon the number input. It should then clear the textfield for the user to continue guessing or to start again. Can anyone help me with the code requied to perfrom this? Thanks in advance.
 
anu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,
I guess first in PV init() method of your applet code you have to call AcionListener for particular TextBox.Then in TextBox ActionPerformed() you have to write your own code.After actionperformed is over you have to clear textbox.
I hope this will help you.
 
Gauri Deshmukh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this might help,
http://eis005.its.utexas.edu/qwicap/example/jsp-bean-numguess.html
http://home.comcast.net/~texture/java.html
[ January 06, 2005: Message edited by: Gauri Deshmukh ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic