Question: use java code thx On the TV game, there are three players who try and guess a phrase. They get to spin a wheel with

use java code thx

On the TV game, there are three players who try and guess a phrase. They get to spin a wheel with different dollar amounts (e.g., $200, $500, $1000, etc). Then they guess a letter. If the letter is in the hidden phrase they get the value that they spun multiplied by the number of the guessed letter in the phrase. For example, if the person spun $200 and guessed 'S' for the hidden phrase "Star Wars", the person would win $400 because there were two letters 'S' in the phrase. The winner of the game is the person who guesses the phrase first and they win all the money that they accumulated during the game.

You are going to write a very simple text version of this game. There will only be one player and three dollar amounts ($200, $500 and $1000) that the player will 'spin' before guessing a letter. The player's jackpot (the amount of money they win on each guess) will keep increasing while they guess letters up to a maximum of 6 letter guesses. If they select a letter that is not in the phrase they will not win any money on that turn (but it counts as a turn) and they cannot try to guess the phrase. The game continues until one of the following occurs:

the player correctly guesses the phrase and they win their 'jackpot', or

the player incorrectly guesses the phrase in which case the game is over, the phrase will be revealed and the player does not win any money, or

the player uses their last of 6 letter guesses - the player gets to select no more than 6 letters, and if they cannot guess the phrase after the 6th letter guess then the game is over, the phrase is revealed, and the player does not win any money.

The Game class will have the following attributes:

The secret phrase (an array of char)

The disguised phrase (another array of char), in which each unknown letter in the secret phrase is replaced with a blank line ( _ ). For example, if the secret phrase is computer science and the letters c and s have been guessed, the disguised phrase would print as

C_ _ _ _ _ _ _ SC _ _ _ C_

The number of guesses made

The number of incorrect guesses

The jackpot amount

The Game class will have the following methods:

spinWheel( ) which returns a random int of 100, 200 or 500

guessLetter(c) guesses that character c (letter c) in the phrase and returns the number of times that letter is in the phrase.

GetDisguisedPhrase( )returns a String containing correctly guessed letters in the correct positions and unknown letters replaced with_.

getSecretPhrase( ) returns the secret phrase.

increaseJackpot(int amt) which increases the jackpot by the amount that turn (number of times the guessed letter is in the phrase x the money amount from the spin)

getGuessCount( ) returns the number of guesses made.

isFound( ) returns true if the hidden phrase has been discovered.

Appropriate constructor and get and set methods (and any others that make sense). Implement the Game class.

Next write a demo class that demonstrates the game. For this class, first create an array of song titles (these titles can be hardcoded as a String array). Select one song title at random from the array as the secret phrase. The following program shows you how to use java.util.Random to select a phrase at random from an array of song titles.

import java.util.Scanner; import java.util.Random; public class RandomWord

{

public static void main(String[] args)

{

String[] songs = {"shake it off", "satisfaction", "mr jones", "uptown funk"}; /ote this is a very short list as an example

Random rand = new Random();

int i = rand.nextInt(songs.length); System.out.println(songs[i]);

}

}

Note: You can also use the Random class to determine the money value from the spin (200, 500, or 1000).

Some pointers:

Keep track of the letters that were guessed (correctly or incorrectly). If the user guesses a letter that they have already guessed, it still decreases their letter guesses. Also, make sure that your program can handle both upper and lower case letters.

You should keep a limit (6) on the number of letter guesses, and quit the game if the user doesnt guess the phrase within the limit. After the sixth letter guess, if the user has not able to guess the phrase the game is over and the user loses (wins no money).

Recall the conversion options between a char array and a String:

String s = new String(phrase);

will convert a char array phrase into a String s.

Similarly,

char[] phrase = s.toCharArray();

will convert a String s into a char array phrase.

You can use the following template for your main method. You should replace the phrase array of songs to a set of song titles of your choice (use at least 8).

import java.util.Scanner; import java.util.Random; public class GameDemo

{

public static void main(String[] args)

{

String[] songs = {"shake it off ", "satisfaction", "mr jones", "uptown funk"}; /ote this is a very short list as an example

Random rand = new Random();

int i = rand.nextInt(songs.length); String secretword = songs[i];

//continue the code here.

}

}

use java code thx On the TV game, there are three playerswho try and guess a phrase. They get to spin a wheel

Round 3: After spinning the wheel, you got $1000. 1 ase gue s s a letter : s+' There is/are 1 s.. Here's how a sample run of what th ike: e program would look Welcome to the Guessing Game. The topic is song titles. You have 6 guesses. Your puzzle has the following letters: Round 1: After spinning the wheel, you got $200. Please guess a letter: e There is/are 1 e.* Do you know the song? (y or n): n. Do you know the song? (y or n) ne Your jackpot is $200- You have 5 guesses left. Your jackpot is $1200 You have 3 guesses left. Round 2:- After spinning the wheel, you got $500. Peas guess a letter av There is no a. Round 4:- After spinning the wheel, you got 1000. Please guess a letter a Too bad - you already guessed a and there is no a. Do you know the song? (y or n): n* Your jackpot is $200- You have 4 guesses left

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!