Question: In Java You will develop two classes for this lab: the Coin class and a Client class that uses instances of the Coin class for

 In Java You will develop two classes for this lab: the

In Java

You will develop two classes for this lab: the Coin class and a Client class that uses instances of the Coin class for playing a game. The objective of the game is to total your coins to exactly one dollar. The game requires three instances of the Coin class: one representing a quarter, one representing a dime and one representing a nickel. When the game begins, your starting balance is $0. During each round of the game, the program will toss the simulated coins. When a coin is tossed, the value of the coin is added to your balance if the coin lands heads-up. For example, if the quarter lands heads-up, 25 cents is added to your balance. Nothing is added to your balance for coins that land tails-up. The game is over when your balance reaches one dollar or more. If your balance is exactly one dollar, you win the game. You lose itf your balance exceeds one dollar or if you quit the game The Coin class should be defines as follows: ik: value - face value of the coin sideUp-a string that holds "HEADS" or "TAILS" indicating the side of the coin that is facing up Methods: A constructor that receives an integer value representing the face value of the coin. Only quarters, dimes, nickels, and pennies should be allowed. If the integer received does not meet this criteria, the value field should be set to 1 (penny is the default.) A void method named toss that simulates the tossing of the coin. When the toss method is called, it randomly determines the side of the coin that is facing up and sets the sideUp field accordingly. A method named getSideUp that returns the value of the sideUp field. A method named getValue that returns the face value of the coin

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!