Question: Create a Coin class that includes a variable faceUp that stores either a 0 for heads up or 1 for tails up, an accessor method
Create a Coin class that includes a variable faceUp that stores either a 0 for heads up or 1 for tails up, an accessor method named showFace that returns a 0 if the coin is heads up or a 1 if the coin is tails up and a modifier method named flipCoin() that assigns a random Integer between 0 and 1, inclusive, to the variable face un dont include a return method for flipCoin Test the class with the following client code: public static void main(String[] args) { Coin nickel = new Coin: nickel (incoino: if (nickel.showFace() == 0) { System.out.println("Heads up"); } else { System.out.println("Tails up!') }Use the following formula to randomize a coin flip (it will return a random integer between 0 and 1): (int)(Math.random() +0.5)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
