
/**
 * Simple class that models a 2-sided coin.
 * 
 * @author Dave Reed
 * @version 1/23/12
 */
public class Coin {
    private Die d2;

    /**
     * Constructor for objects of class Coin.
     */
    public Coin() {
        this.d2 = new Die(2);
    }

    /**
     * Simulates a single flip of the coin.
     *   @return either "HEADS" or "TAILS" with equal likelihood
     */
    public String flip() {
        int rollResult = this.d2.roll();
        if (rollResult == 1) {
            return "HEADS";
        }
        else {
            return "TAILS";
        }
    }
    
    /**
     * Identifies how many times the coin has been flipped.
     *   @return the number of flips so far
     */
    public int getNumFlips() {
        return this.d2.getNumRolls();
    }
}
