Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your solution should use all three files listed above. The Coin.h file (class specification file) should contain the class declaration, the declaration of the member

Your solution should use all three files listed above.

The Coin.h file (class specification file) should contain the class declaration, the declaration of the member variables, and prototypes for the constructor and the member functions. Nothing should be implemented in this file.

The Coin.cpp file (class implementation file) should contain the implementation of the constructor and the member functions.

The main.cpp file (application program) should contain the game logic for the coin toss game.

The Coin class should have the following member variable:

A string named sideUp.The sideUp member variable will hold either heads or tails indicating the side of the coin that is facing up.

The Coin class should have the following member functions:

A default constructor that randomly determines the side of the coin that is

facing up (heads or tails) and initializes the sideUp member variable accordingly.

A void member function named toss that simulates the tossing of the coin. When the toss member function is called, it randomly determines the side of the coin that is facing up (heads or tails) and sets the sideUp member variable accordingly.

A member function named getSideUp that returns the value of the sideUp member variable.

The player (you) and the computer both begin with a starting balance of $0.00. For each round of the game, both the player and the computer toss a quarter, a nickel, and a dime. For each type of coin, if the coin lands on heads, the amount of the coin is added to the players balance. If the coin lands on tails, however, nothing is added to the players balance for that coin.

The game ends when at least one player has a balance of $1.00 or more. The following are conditions for win/loss/tie:

- If both players have the same balance at the end, they tie (note that this means both players not only have the same score, but their shared score is $1.00 or more)

- If one player has a balance of less than $1.00 when the game ends, the other player who has a balance of $1.00 or more wins. For example, if the player has $0.90 and the computer has $1.05, the computer with $1.05 wins (remember its not possible for both players to have less than $1.00 when the game ends)

- If both players have a balance of $1.00 or more, the player with the lower score wins. For example if the player ends the game with $1.10, and the computer ends the game with $1.30, the player with $1.10 wins.

As you will see from the sample runs, there is NO user input for this game. Again, the game automatically ends when one or both players have a balance of $1.00 or more.

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions