Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a Java Program- Guessing Game Project Outcomes: To develop skills in using the Java selection constructs (if, and if else). Use the Java iteration

write a Java Program- Guessing Game

Project Outcomes:

To develop skills in using the Java selection constructs (if, and if else).

Use the Java iteration constructs (while, do, for).

Use Boolean variables and expressions to control iterations.

Random number generation.

Proper Design techniques including reading UML Class Diagrams

1) Develop a simple class that represents a number guessing game. The game is played by the program randomly generating a number and the user attempting to guess that number. After each guess the program will provide a hint to the user identifying the relationship between the number and the guess. If the guess is above the answer then Too High is returned, if the guess is below the answer then Too Low. Also if the difference between the answer and the guess is less than the difference between the answer and the previous guess, Getting warmer is returned. If the difference between the answer and the guess is more than the difference between the answer and the previous guess, then Getting Colder is returned.

GuessingGame

MAXGUESSESALLOWED : int

answer : int

generator : Random

gameOver : boolean

differential : int

max : int

numGuessesTaken:int

GuessingGame()

GuessingGame (int)

newGame(int) guess(int) : String

isGameOver() : boolean

2) The program will allow the user to play multiple games. Once a game is complete the user will be prompted to play a new game or quit.

3) Design and build a GuessingGame class.

a. One constant

i. MAXGUESSESALLOWED

ii. an int that represents the maximum number of guesses the user gets, once this value is passed the game is over. (set to 6)

b. Seven instance variables.

i. answer - an integer representing the randomly generated number.

ii. generator a random Generator object (create from the Java API Random class) (pg 250 in text)

iii. gameOver a Boolean, false if game still in progress, true if the game is over.

iv. differential an integer representing the difference between a guess and the answer.

v. max maximum value of the number to guess. For example, if the maximum number is 100 then the number to guess would be between 0 and 100.(inclusive)

vi. numGuessesTaken an integer that stores the number of guessed taken so far in any game.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions