Starting from:
$35

$29

PROGRAM TWO CROCKETTLAND GAME SOLUTION




DESCRIPTION:







You are writing a game where your players navigate through an imaginary world (board) using an imaginary dice. Your imaginary world has good things and bad things in it. Each player begins the game with zero money in their account and on board space zero. Each player has a turn where all they do is roll a dice. When a player lands on a space, either good or bad is selected randomly. If good, then something good happens to the player, a smiley face is printed, and money is added to their account. If bad, then something bad happens to the player, a frown face is printed, and money is subtracted from their account. The game ends when a player lands on or goes past the ending space on the board.







CONSTANT VARIABLES







Maximum Number of Players possible: 20



Number of Spaces on Board: 25






OVERALL PROGRAM







You will have three arrays:



names – will hold the names of players playing the game. Example: names[0] could hold April Crockett and



names[1] could hold Jason Crockett if April & Jason are currently playing the game.




boardSpace – will hold the current location (space) of players playing the game. Example: boardSpace[0] could hold 15 and boardSpace[2] could hold 6 if April was currently at space 15 on the board and Jason was currently at



space 6 on the board.




money –will hold how much money each player has playing the game. Example: money[0] could hold 50000 and money[1] could hold -4000 if April currently had $50,000 and Jason had -$4,000. (yes – people can have a negative balance in the game!)
You will allow your players to play the game as many times as they want



You can name your imaginary land whatever you want.



You will create two text files – bad.txt and good.txt. There is more details on this later in this document.






PROGRAM SPECIFICATIONS / FLOW







Print out the name of your imaginary land/game. (Mine is called CROCKETTLAND – but you can name yours whatever you want)



Ask user how many players are playing and validate that they didn’t enter more than the maximum number of players – and that it is more then zero.



Set up your arrays for the start of the game! Set each element of names array to an empty string, each element of boardSpace array to zero, and each element of money array to 0.0.



Get each player’s name and place their name in each element of the names array. Notice when the player’s names are printed out in the samle output. Your program should print out the player’s names in the same way.



Create a loop that will iterate until one of the players has reached the last space on the board.



Create another loop to iterate through each of the players for each turn. For each player’s turn, you will:



Print out the player’s name and tell them to press enter to roll die.



Randomly generate a number between 1 & 6 (for the dice roll)



Print a cool picture of the dice that was rolled



code given to you in dice.cpp



Add the randomly generated number to the position in the boardSpace array that corresponds to the current player.



If they have reached the end of the board, then print out that they finished the board and then print the results (explained in its own section below).



If they have not reached the board, then…



Print out their current board space and then display what happens on the space (explained in its own section below).
Randomly generate a number between $1 and $100,000 for the money amount.



If a good thing happened, then add the random money amount to the money array for the current player and print out how much was added. Otherwise, if a bad thing happened, then subtract the money from the money array for the current player and print out how much was subtracted.
Print out how much money the player has in his or her account.



After a player reached the ending space on the board and the results have all been printed, then ask the user if they want to play again.
 
DISPLAY WHAT HAPPENS ON THE SPACE



Display what happens on the space – good or bad. There are two text files containing the text of what happens. You will have to create each text file by opening notepad or another editor and manually typing them. The good.txt text file should contain 20 good things that can happen to the player. The bad.txt text file should contain 20 bad things that can happen to the player.




First, randomly generate either a 1 or 2. 1 will represent something good happening and 2 will represent something bad happening.



If good, then…



Open the good.txt file



Print out a big smiley face (doesn’t have to look exactly like mine but it has to be happy)



Print the word “GREAT! “ (or something similar)



If bad, then…



Open the bad.txt file



Print out a big frowny face (doesn’t have to look exactly like mine but it has to be sad)



Print the word “OH NO! “ (or something similar)



Then randomly generate a number between 1 & 20.



Use a for loop that iterates the number of times that was randomly generated in the step above.



In the for loop, read in a line from the file using getline.



After the for loop, print out the line from the file






PRINT THE RESULTS




This code should execute when one of the players reached the last space on the board. It will display the results of the game – who reached the end of the board and also who ended up with the most money.




Use a for loop to iterate through the boardSpace array and find the player who reached the highest boardSpace. Capture this player’s name.



Print out the player who had the highest board space.



Use a for loop to iterate through the money array and find the player who had the most money at the end of the game. Capture this player’s name.



Print out the player who had the most money.

More products