Question: This is all in java (B) Write a driver class called Fun WithCoins. Implement a static method called alternate that takes an int size as

 This is all in java (B) Write a driver class called

This is all in java

(B) Write a driver class called Fun WithCoins. Implement a static method called alternate that takes an int "size" as argument and creates an array of "size" Coin objects (Coin class is provided below). Return the number of times alternate coins in the array have the same face "heads" or "tails". (For example, if size is 10, and the Coin array is built this way: HTTHTHHIIT then the program should return 3. (It has one HTH, one THT and one TTT, all of which will be counted).) Test your code by calling the method alternate in your main program. Coin Class (copy and paste this code to get started) public class Coin private String face; public Coin() flip(); public void flipo intr= (int)(Math.random()*2); if (r==0) face = "H"; else face = "T": } public String getFace() return face; public void setFace(String s) iffs.equalsignoreCase("head") || s.equalsignoreCase("heads") || s.equalsignoreCase("h")) face = "H"; else if(s.equalsignore Case("tail") || s.equalslgnoreCase("tails") || s.equalslgnore Case("t")) face = "T"; else face = "ERROR": }

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!