/* Java application illustrating the use of objects of the TossableCoin1 class. */ public class TossableCoin1App { public static void main(String[] args) { // Create a new coin object and assign it to variable 'coin'. TossableCoin1 coin = new TossableCoin1(); // Toss the coin several times, each time displaying the result. // Also, keep track of how many times each of HEADS and TAILS was // tossed. int headsCntr = 0, tailsCntr = 0; for (int i=1; i <= 10; i = i+1) { coin.toss(); System.out.println(coin); if (coin.isHeads()) { headsCntr = headsCntr + 1; } else { tailsCntr = tailsCntr + 1; } } // Report how many times each of HEADS and TAILS was tossed. System.out.println("\n# times Heads was tossed: " + headsCntr); System.out.println("# times Tails was tossed: " + tailsCntr); } }