The Artima Developer Community
Sponsored Link

Java Answers Forum
I want to create a game, BUT HOW?

2 replies on 1 page. Most recent reply: Nov 29, 2002 1:38 AM by Sreekanth

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Ernie Douglas

Posts: 18
Nickname: y2j
Registered: Nov, 2002

I want to create a game, BUT HOW? Posted: Nov 22, 2002 11:17 AM
Reply to this message Reply
Advertisement
can anyone help, i want to write an APPLET that plays the "guess the number" game as follows: the program chooses the number to be guessed at by selecting a random integer in the range 1 to 1000. The applet displays the prompt 'Guess a number between 1 and 1000' next to a JTextField. The player types a first guess into the JTextField and presses the Enter key. If the player's guess is incorrect, your program should display "Too high. Try again" or "Too low. Try again" in the status bar to help the player 'zero in' on the correct answer and should clear the JtextField so the user can enter the next guess.
When the player enters the correct answer, display one of the following messages, depending on how many attempts the player took to get the answer right: If the number of guesses was fewer than 10, print "Congratulations. You guessed the number in n guesses - either you know the secret or got lucky!" where n is the actual number of attempts taken. If the number of guesses was exactly 10, print "Congratulations. You guessed the number in 10 guesses". If the player takes more than 10 guesses, print "You took n guesses. You should be able to do better!" again, where n is the actual number of attempts taken.

once the application is working, i want to modify it to allow the player to enter their first name and the number range to use (e.g., 1 - 100, 20 - 2000, etc...) Change the output to display the player's name as well as the appropriate output message. i aslo need to Calculate the number of guesses that a player should take to find the random number given the inputted range, and use this value, rather than 10, when deciding which of the three final output messages to display when the player successfully guesses the random number. so if anyone knows this coding, PLEASE PLEASE PLEASE SHOW ME. i am new at this and frankly books r no help at all to me, thank you


Daniel Ray

Posts: 53
Nickname: budoray
Registered: Oct, 2002

Re: I want to create a game, BUT HOW? Posted: Nov 26, 2002 10:16 AM
Reply to this message Reply
You can find source for things like this through google. If you still need help .. I'd be happy to get you going. I might be wrong, but the Dietel dudes <grin> had a C++ book with the same type of problem and how to solve it (no applet of course) and I think their Java book is the same format. That might be another place to look.

Ray

Sreekanth

Posts: 9
Nickname: sree
Registered: Nov, 2002

Re: I want to create a game, BUT HOW? Posted: Nov 29, 2002 1:38 AM
Reply to this message Reply
The same game comes along with tomcat server JSP examples.Install tomcat server and go to its homepage(http://localhost:8080/index.html)-- then go to JSP Examples link, there you'll get numberguess example.

Flat View: This topic has 2 replies on 1 page
Topic: dear Moderator. Please block homework requests Previous Topic   Next Topic Topic: Decompiler inJAVA!!!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use