Coins - CS 1050 Dr Tucker Spring 2009 Coin.java Author...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 1050, Dr. Tucker Spring 2009 //******************************************************************** // Coin.java Author: Lewis and Loftus, Java Software Solutions, 3 rd ed // 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. //-----------------------------------------------------------------
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online