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 [73 marks]
[15 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 1 Tails Tails
flip 2 Tails Tails
flip 3 Tails Tails
flip 4 Tails Heads
flip 5 Tails Heads
flip 6 Heads Tails
flip 7 Tails Heads
flip 8 Heads Tails
flip 9 Heads Heads
flip 10 Tails Tails
flip 11 Heads Heads
flip 12 Heads Tails
flip 13 Heads Tails
First coin is the winner after 13 flips
The API for Coin class is:
public Coin 0
// default constructor
public void nlip0
//Flips the coin by randomly choosing a face value.
public boolean isHeads 0?? Returns true if the current face of the coin is heads
public String toString0
cannot be used to some preliminary isting 6.1 prints a
 PART B: PROGRAMMING QUESTION [73 marks] [15 marks] Using 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!