Question: PART B: PROGRAMMING QUESTION [ 7 3 marks ] [ 1 5 marks ] Using the Coin class with the API shown below design and
PART B: PROGRAMMING QUESTION marks
marks
Using the Coin class with the API shown below design and implement the driver class FlipRace which creates two Coin objects, then continually flips them both to see which coin comes up Heads three flips in a row. Continue flipping the coins until one coin wins the race and also consider the possibility that both coins achieve the objective in the same time that will be a tie Print the results of each turn and at the end print the winner and the total number of flips that were required.
Possible output:
flip Tails Tails
flip Tails Tails
flip Tails Tails
flip Tails Heads
flip Tails Heads
flip Heads Tails
flip Tails Heads
flip Heads Tails
flip Heads Heads
flip Tails Tails
flip Heads Heads
flip Heads Tails
flip Heads Tails
First coin is the winner after flips
The API for Coin class is:
public Coin
default constructor
public void nlip
Flips the coin by randomly choosing a face value.
public boolean isHeads Returns true if the current face of the coin is heads
public String toString
cannot be used to some preliminary isting prints a
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
