/*
 * File: Coin.java
 * Purpose: Represents a coin with two sides that can be flipped.
 * 
 * Authors: Lewis, Loftus, Pollack
 * Updated: 7-26-00 - 18:30
 */

public class Coin {
    public final int HEADS = 0;
    public final int TAILS = 1;
    
    public Coin() {             // Constructor - create and initialize a coin
        flip();
    }

    public void flip() {        // Flips the coin once
        nFace = (int) (2 * Math.random());
    }

    public int getFace() {      // Accessor - returns the face
        return nFace;
    }

    public String toString() {  // Convert face to human-readable form
        String sFaceName = (nFace == HEADS) ? "Heads" : "Tails";
        return sFaceName;
    }

    private int nFace;          // the face of the coin    
}
