Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Ryan Blume
- //12/6/19
- //Classes Practice
- public class Coin
- {
- private final int HEADS = 0;
- private static int TAILS = 1;
- private int face;
- public Coin()
- {
- flip();
- }
- public void flip()
- {
- face = (int)(Math.random()*2);
- }
- public boolean isHeads()
- {
- return(face==HEADS);
- }
- public String toString()
- {
- String faceName;
- if(face==HEADS)
- {
- faceName = "heads";
- }
- else
- {
- faceName = "tails";
- }
- return faceName;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement