Question: c++ this is assign.cpp file this is Coin.cpp file this is Coin.h file The Coin class should have the following member variable: + A string
c++








this is assign.cpp file

this is Coin.cpp file

this is Coin.h file


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 side Up member variable accordingly. A member function named getSideUp that returns the value of the sideUp member variable. U II The game works as follows (as you will see in the sample runs below): 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 player's balance. If the coin lands on tails, however, nothing is added to the player's balance for that coin. For example: The player gets heads for the quarter, heads for the dime, and tails for the nickel. $0.25 + $0.10 = $0.35 is added to the players balance for that round. The computer gets tails for the quarter, tails for the dime, and heads for the nickel. $0.05 is added to the computer's balance for that round. The maximum amount that can be added to a player's balance in a single round is $0.25 + $0.10 + $0.05 = $0.40 (heads for all three coins). The minimum amount that can be added to a player's balance in a single round is $0.00 (tails for all three coins). Coin.cpp UML Diagram for the Coin class: Coin -sideUp: string // Stores either "heads" or "tails" > +Coin() +toss() +getSideUp(): string 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 it's 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 Your starting balance: $0.00 The computer's starting balance: $0.00 Your balance after round 1: $0.40 The computer's balance after round 1: $0.15 Your balance after round 2: $0.40 The computer's balance after round 2: $0.20 Your balance after round 3: $0.45 The computer's balance after round 3: $0.35 Your balance after round 4: $0.55 The computer's balance after round 4: $0.70 Your balance after round 5: $0.70 The computer's balance after round 5: $0.70 Your balance after round 6: $0.85 The computer's balance after round 6: $0.80 Your balance after round 7: $1,10 The computer's balance after round 7: $1.10 Your ending balance: $1.10 The computer's ending balance: $1,10 Tie! Nobody wins. Press any key_to continue. Your starting_balance: $0.00 The computer's starting balance: $0.00 Your balance after round 1: $0.15 The computer's balance after round 1: $0.09 Your balance after round 2: $0.20 The computer's balance after round 2: $0.30 Your balance after round 3: $0.50 The computer's balance after round 3: $0.30 Your balance after round 4: $0.65 The computer's balance after round 4: $0.65 Your balance after round 5: $0.95 The computer's balance after round 5: $0,75 Your balance after round 6: $1,10 The computer's balance after round 6: $1,05 Your ending balance: $1.10 The computer's ending balance: $1.05 Sorry! The computer won, Press any key to continue... Your starting_balance: $0.00 The computer's starting balance: $0.00 Your balance after round 1: $0.10 The computer's balance after round 1: $0.15 Your balance after round 2: $0.35 The computer's balance after round 2: $0.40 Your balance after round 3: $0.70 The computer's balance after round 3: $0.40 Your balance after round 4: $0.85 The computer's balance after round 4: $0.75 Your balance after round 5: $0.85 The computer's balance after round 5: $0.75 Your balance after round 6: $1.20 The computer's balance after round 6: $0.85 Your ending balance: $1.20 The computer's ending balance: $0.85 Congratulations! You won. Press any key to continue... // Application Program #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
