Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming Electricity tariffs Hello, can somebody help me with this task I would need a finished, running program to compare. Happiness house Background: The

C++ Programming Electricity tariffs

Hello, can somebody help me with this task

I would need a finished, running program to compare.

Happiness house

image text in transcribed

Background:

The game 'Glckshaus' from the late Middle Ages is a game of chance that is played with two dice, a game board (see example on the right) and (game) coins. The aim is to win the coins of the other players. Course of the game: At the beginning each player has to put a certain number of coins on the table. The two dice are rolled in turn, the eyes are added together:

Total 3, 5, 6, 8, 9, 10, 11: If the field with this number on the playing field is empty, the player must put one of his coins on the field. If there is already a coin there, he may take it instead.

Total 4: Nothing happens, it's the next player's turn.

Total 7: A coin must be placed on the field with the 7, regardless of whether there are others there or not.

Total 2: The coins from the whole board - except for the field with the 7 - can be taken.

Total 12: The coins from the whole board - including the field with the 7 - may be taken.

End of the game: The game ends when all but one of the players have lost their coins.

Task:

You should realize an object-oriented simulation of the game 'Glckshaus' and simulate a series of games according to different specifications. To do this, use the HouseOfFortune class and the Player class:

image text in transcribedimage text in transcribed

The following applies to the data elements and element functions:

The array board represents the playing field with its 11 fields. The global constant for the array size has at least the value BOARD_SIZE = 11. If you want to make things a little easier, you can also choose BOARD_SIZE = 13 and both leave the first array spaces unused.

nextPlayer is given the player whose turn it is next. The function lets the transferred player roll the dice and remembers the number of points. Then it determines the win or loss according to the rules of the game (see above: course of the game) and hands over the won coins from the playing field to the player or takes a raffled

Take a coin from the player and place it on the field. In addition, nextPlayer returns the number rolled by the player.

noOfCoinsOnBoard counts all coins that are currently on the playing field and returns this number.

Player's constructor takes the name of the player and the number of coins he is playing with from outside. It also generates the id of every new player object by setting id to the value of the (static) class variable idPool and then increasing idPool by one. At the beginning, idPool has the value 0. The created player objects are given the id values 0, 1, 2, 3, 4, 5 one after the other.

rollDice simulates the throwing of two dice and returns the rolled total.

winCoins receives a number of coins from the playing field and increases the noOfCoins of the player accordingly.

looseCoin gives a coin to the playing field, i.e. the noOfCoins of the player is decreased by one and this one coin is returned for further processing. When the player has given his last coin, he is eliminated from the game.

outOfGame returns true if the player is eliminated as long as he is still playing, i.e. false.

The application (main) should perform the following actions in sequence (no menu, no user entries!):

Creation of a HouseOfFortune object and creation of the list of participants in the form of a vector with 6 players named Abel, Bert, Carl, Dirk, Erni and Fred (in this order). All start with 6 coins. Implementation of 20 game rounds, in which all players have their turn in alphabetical order and output of (please all in one line, see below!): Number of the game round, the number of coins the player has and the number of coins on the playing field before the current -Own play, the player's name, the number he rolled, the number of coins the player has and the number of coins on the field after the current move. Immediately after losing the last coin of a player, it should be issued that this player has been eliminated and he is removed from the list of participants. A section of the desired output could look like this:

image text in transcribed

After the 20 game rounds, all players remaining in the game are to be given out in descending order of the number of their coins with their name and number of coins. In addition, the number of coins that are currently on the playing field should be issued.

A number of games with the same 6 players as above should each be played to the end; So there should only be one player left for each game. If the penultimate player is eliminated, the last player wins immediately, so the current round will no longer be played. In contrast to the above, the players should not have all 6 coins at the beginning, but the first (Abel) has 6, the second (Bert) has 5, the third (Carl) has 4, etc., so that the sixth (Fred) only has one coin at the beginning. Does Fred even have a chance of stealing all coins from his fellow players and if so, how big is this chance? To answer this question, simulate 10,000 complete games and (only!) Output a table showing the player name, his id and the number of games he has won as an absolute numerical value and as a percentage contains the total number of games. The table should contain the players in alphabetical order.

12. 9 10 11 6 7 8 3 4. 5 2. HouseOfFortune board: array + nextPlayer (Player): int + noofCoinsOnBoard (): int - Player name: string id: int noofCoins: int idPool: int + Player (string, int) + rollDice (): int + winCoins (int): void + looseCoin(): int + getName(): string + getId(): int + getNoOfCoins (): int + outofGame (): bool + setIdPool (int) : void fakultativ: + operator + nextPlayer (Player): int + noofCoinsOnBoard (): int - Player name: string id: int noofCoins: int idPool: int + Player (string, int) + rollDice (): int + winCoins (int): void + looseCoin(): int + getName(): string + getId(): int + getNoOfCoins (): int + outofGame (): bool + setIdPool (int) : void fakultativ: + operator

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago