Coin - /* / Coin.java Author: Lewis/Loftus / / Solution to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // Coin.java Author: Lewis/Loftus // // Solution to Programming Project 5.6 //******************************************************************** / import java.util.Random; i public class Coin implements Lockable { private final int HEADS = 0; private final int TAILS = 1; private final int LOCK = 3; private boolean locked; private int coinKey; private int face; //----------------------------------------------------------------- // Sets up the coin by flipping it initially. //----------------------------------------------------------------- public Coin () { locked = false; coinKey = 0; flip(); } //----------------------------------------------------------------- // Flips the coin by randomly choosing a face value. //----------------------------------------------------------------- public void flip () { if (!locked) face = (int) (Math.random() * 2); } //-----------------------------------------------------------------
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Page1 / 2

Coin - /* / Coin.java Author: Lewis/Loftus / / Solution to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online