// Program Name                  Coin.java
// Course:                       CSE 1302J
// Student Name:                 Bradley Shedd
// Assignment Number:            Lab1
// Due Date:                     08/23/2010
// Purpose:                      This program will calculate the number of times a coin lands on heads or tails.              
// Coin.java                     Author: Lewis and Loftus
//
//   Represents a coin with two sides that can be flipped.
// *******************************************************************

public class Coin
{
   
public final int HEADS = 0;
   
public final int TAILS = 1;

   
private int face;

   
// ---------------------------------------------
    //   Sets up the coin by flipping it initially.
    // ---------------------------------------------
    public Coin ()
    {
       
   flip();
    }

   
// -----------------------------------------------
    //   Flips the coin by randomly choosing a face.
    // -----------------------------------------------
    public void flip()
    {
   face = (
int) (Math.random() * 2);
    }

   
// -----------------------------------------------------
    //   Returns the current face of the coin as an integer.
    // -----------------------------------------------------
    public int getFace()
    {
  
return face;
    }

   
// ----------------------------------------------------
    //   Returns the current face of the coin as a string.
    // ----------------------------------------------------
    public String toString()
    {
   String faceName;

  
if (face == HEADS)
       faceName =
"Heads";
  
else
       faceName = "Tails";

  
return faceName;
    }
}
public class BiasedCoin
{
  
private double BIAS = 

Homepage