Advertisement
ryanblume11

zach this is for you

Dec 6th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. //Ryan Blume
  2. //12/6/19
  3. //Classes Practice
  4. public class Coin
  5. {
  6. private final int HEADS = 0;
  7. private static int TAILS = 1;
  8.  
  9. private int face;
  10. public Coin()
  11. {
  12. flip();
  13. }
  14. public void flip()
  15. {
  16. face = (int)(Math.random()*2);
  17.  
  18. }
  19. public boolean isHeads()
  20. {
  21. return(face==HEADS);
  22. }
  23. public String toString()
  24. {
  25. String faceName;
  26. if(face==HEADS)
  27. {
  28. faceName = "heads";
  29.  
  30. }
  31. else
  32. {
  33. faceName = "tails";
  34. }
  35. return faceName;
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement