public class Coin { public static final int HEADS = 0 ; public static final int TAILS = 1 ; private int face ; private int value ; public Coin(int value) { this.value = value ; flip(); } public void flip() { face = (int) (Math.random() * 2); } public int getFace() { return face; } public int getValue() { return value; } public String toString() { String facename; if( face == HEADS ) { facename = "heads"; } else { facename = "tails"; } return ( Integer.toString(value) + " cent coin, face: " + facename ); } }
Additional info: Reading user input using Scanner
Results of the labs and assignments that do not involve usage of web server should be submitted as follows: