Guest User

Untitled

a guest
Oct 20th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class Coin {
  2. public final int HEADS = 0;
  3.  
  4. Coin quarter = new Coin();
  5. Coin dime = new Coin();
  6. Coin nickel = new Coin();
  7.  
  8. private static int face;
  9. private static int coin;
  10.  
  11. public static void flip() {
  12. coin = (int) (Math.random() * 3);
  13. face = (int) (Math.random() * 2);
  14. }
  15.  
  16. public String toString() {
  17. String sideUp;
  18. if (face == HEADS) {
  19. sideUp = "Heads";
  20. } else {
  21. sideUp = "Tails";
  22. }
  23. return sideUp;
  24. }
Add Comment
Please, Sign In to add comment