Advertisement
tjb1

Untitled

Nov 28th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Chap5prob20_coinTOSS {
  4. private String sideUp = "";
  5.  
  6. public Chap5prob20_coinTOSS() {
  7. sideUp = "heads";
  8. }
  9.  
  10. //all other object specific methods
  11.  
  12.  
  13.  
  14. public void settoss() {
  15. int toss = 0;
  16. Random test = new Random();
  17. toss = test.nextInt(2);
  18. if(toss == 0){
  19. sideUp = "heads";
  20. }
  21. else {
  22. sideUp = "tails";
  23. }
  24. }
  25.  
  26. public String gettoss() {
  27. return sideUp;
  28. }
  29. }//end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement