package edu.bloomu.ch5a;

import java.util.concurrent.ThreadLocalRandom;

/**
 * Outputs the results of three simulated coin flips. 
 * 
 * @author Drue Coles
 */
public class CoinFlip {

    public static void main(String[] args) {

        ThreadLocalRandom rand = ThreadLocalRandom.current();
        
        // first flip: using two if statements
        System.out.print("Coin flip 1: ");
        boolean heads = rand.nextBoolean();
        if (heads) {
            System.out.println("HEADS");
        }
        if (!heads) {
            System.out.println("TAILS");
        }
        
        // second flip: using an if-else statement
        System.out.print("Coin flip 2: ");
        if (rand.nextBoolean()) {
            System.out.println("HEADS");
        } else {
            System.out.println("TAILS");
        }
        
        // third flip: using if-else operator
        System.out.print("Coin flip 3: ");
        System.out.println(rand.nextBoolean() ? "HEADS" : "TAILS");
    }
}