Code A Wheel Of Fortune Game

Posted on  by 

Can't decide?
Wheel Decide for you!

I'm trying to design the classes for the Wheel of Fortune game in Java. The below diagram represents the classes and the interaction between them. Below is the partial implementation of it.



You'll have to take our word for it that the wheel landed on Japanese. Your browser cannot display the wheel of choices. Please upgrade to a newer browser that supports HTML5 (most new ones do). Wheel Decide would normally show a wheel right here with choices that you can set (lunch, games, dinner, anything!). You can spin it to get a random decision. Make your own wheel of dinner, wheel of fortune, wheel of lunch, wheel of whatever you want now!
Game

Wheel Of Fortune Word Lists


Wheel Of Fortune Online Game For Free


Paste into the text box below with one choice per line and then click the 'Add Choices' button

On Windows, use ctrl+v or right click the textbox and paste
On Mac, use command+v or right click the textbox and paste
Copy/Paste Help

Replace Choices (all current choices will be removed and replaced by the new list)
wheel_of_fortune.py

Wheel Of Fortune Questions Printable

###############################FUNCTIONS CREATED BY GROUPS####################################
#INTERMEDIATE GROUP 1
#TAKES A STRING INPUT AND RETURNS A STRING THAT HAS ALL THE
#LETTERS REPLACED WITH DASHES (THE SPACES REMAIN AS SPACES)
defreplaceWithDashes(string):
dashes='
#fill in here
returndashes
#INTERMEDIATE GROUP 2
#FUNCTION THAT TAKES THREE INPUTS: THE CURRENT PHRASE (MOSTLY DASHES), THE SPOT IN THE
#PHRASE TO BE REPLACED, AND THE ORIGINAL PHRASE. THIS FUNCTION REPLACES THE DASH AT THE GIVEN
#SPOT WITH THE LETTER FROM THE ORIGINAL PHRASE. IT RETURNS THE NEW STRING
defrevealSpotInPhrase(phrase,spot,original_phrase):
#fill in here
returnnew_phrase
#BEGINNER GROUP 1
#FUNCTION THAT TAKES ONE INPUT OF THE CURRENT PLAYERS TURN
#IF IT IS CURRENTLY THE 1ST PLAYERS TURN, THIS FUNCTION RETURNS 2
#IF IT IS CURRENTLY THE 2ND PLAYERS TURN, THIS FUNCTION RETURNS 1
defnextPlayersTurn(current_turn):
#fill in here
returnnextTurn
#BEGINNER GROUP 2
#FUNCTION THAT TAKES A STRING AND A LETTER AS AN INPUT
#IT RETURNS THE STRING 'true' IF THE LETTER APPEARS IN THE STRING AND THE
#STRING 'false' IF IT DOES NOT. ALSO PRINTS A MESSAGE TO LET THE PLAYER KNOW
defisLetterInPhrase(string,letter):
#fill in here
return'false'
#BEGINNER GROUP 3
#FUNCTION THAT TAKES A LETTER AS AN INPUT AND RETURNS THE
#STRING 'true' IF IT IS A VOWEL AND 'false' IF IT IS NOT
defisGuessAVowel(letter):
#fill in here
return'false'
##################################FUNCTIONS PROVIDED###########################################
#PROVIDED, BUT CAN MODIFY
#FUNCTION THAT DOESN'T HAVE ANY INPUTS AND USES THE GAME'S VARIABLES TO
#PRINT THE CURRENT PHRASE, THE PLAYERS TURN, AND THEIR SCORE
defprintGameState():
print('******************************************************')
ifplayerTurn1:
print(player1Name+'s turn, $'+str(player1Score))
else:
print(player2Name+'s turn, $'+str(player2Score))
print('Board: '+current_phrase)
#PROVIDED, BUT CAN MODIFY
#FUNCTION THAT DOESN'T HAVE ANY INPUTS AND USES THE GAME'S VARIABLES TO
#PRINT THE FINAL PHRASE AND THE WINNER
defgameOverMessage():
#PRINT OUT FINAL PHRASE, WINNER
print('******************************************************')
print('Game Over!')
print('Board: '+original_phrase)
print(player1Name+'s Score: '+str(player1Score) +', '+player2Name+'s Score: '+str(player2Score))
ifplayer1Score>player2Score:
print(player1Name+' wins!')
else:
print(player1Name+' wins!')
#PROVIDED, BUT CAN MODIFY
#RETURNS A RANDOM NUMBER BETWEEN 1 AND 10
#THE GAME LOGIC WILL USE THIS FUNCTION TO MAKE 1 - LOSE TURN,
#2 - BANKRUPT, #3 - $300, 4 - $400, ETC.
importrandom
defspinWheel():
spin=random.randint(1,10)
returnspin
#PROVIDED
#FUNCTION THAT READS IN THE PLAYERS GUESS FOR A LETTER AND RETURNS
#THE UPPERCASE OF IT
#NOTE: THIS CAN BE ENHANCED TO 1) VERIFY EXACTLY ONE LETTER WAS TYPED IN
#2) VERIFY THE LETTER HASN'T BEEN GUESSED BEFORE
defplayerGuess():
guess=raw_input('Your guess: ')
guess=guess.upper()
returnguess
#PROVIDED
#FUNCTION THAT TAKES THE CURRENT PHRASE, ORIGINAL PHRASE, AND GUESS AS INPUTS
#IT CALLS THE revealSpotInPhrase FUNTION TO REPLACE ALL THE DASHES FOR THE GUESSED
#LETTER. IT RETURNS THE NEW PHRASE WITH THE DASHES REPLACED
defrevealAllOfGuess(current_phrase, original_phrase, guess):
count=original_phrase.count(guess)
startSpot=0
new_phrase=current_phrase
foriinrange(0, count):
replaceSpot=original_phrase.find(guess, startSpot)
new_phrase=revealSpotInPhrase(new_phrase,replaceSpot, original_phrase)
startSpot=replaceSpot+1
returnnew_phrase
#PROVIDED
#FUNCTION THAT TAKES THE CURRENT PLAYERS NUMBER AS AN INPUT AND
#UPDATES THAT PLAYERS SCORE VARIABLE TO ZERO
#Note: 'global' is needed to modify the variable in a function
defmakePlayerBankrupt(playerNumber):
ifplayerNumber1:
globalplayer1Score
player1Score=0
else:
globalplayer2Score
player2Score=0
#PROVIDED
#FUNCTION THAT TAKES THE CURRENT PLAYERS NUMBER AND AMOUNT TO INCREASE AS
#INPUTS. IT ADDS THE AMOUNT TO THE PLAYERS SCORE
#Note: 'global' is needed to modify the variable in a function
defaddToPlayersScore(playerNumber,amount):
ifplayerNumber1:
globalplayer1Score
player1Score=player1Score+amount
else:
globalplayer2Score
player2Score=player2Score+amount
##########################PLAY THE GAME USING THE FUNCTIONS ABOVE###############################
original_phrase='THE SAN FRANCISCO GIANTS'
current_phrase=replaceWithDashes(original_phrase)
#print the welcome message and ask for player names
print('Welcome to Wheel of Fortune!')
player1Name=raw_input('Player 1 name: ');
player1Score=0
player2Name=raw_input('Player 2 name: ');
player2Score=0
playerTurn=1
#REPLACE THIS PSUEDO-CODE WITH PYTHON TO PLAY THE GAME
#while the game is not over
#print the current game state
#spin the wheel
#if spin is 1, lose turn
#print message
#set playerTurn to next players turn
#else if spin is 2, go bankrupt
#print message
#set players money to 0
#set playerTurn to next players turn
#else spin was a $
#print message that your spin money was 100 times spin value
#take user input for guess
#if the letter is in the phrase
#reveal the letters in the phrase
#if the letter is a consonant (vowels don't make money)
#change the player's score (add the letter count times spin money)
#else set playerTurn to next players turn
#print the game over message
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Coments are closed