Advertisement
Guest User

Untitled

a guest
May 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public class Deal
  2. {
  3. //instance variables
  4. private int prizeLoc;
  5. private int userGuess;
  6.  
  7. //constructor
  8. public Deal()
  9. {
  10. setPrizeLoc();
  11. setUserGuess();
  12. }
  13.  
  14. //modifier method for prizeLoc (should call random number method)
  15. public void setLoc(int loc) {
  16. prizeLoc = loc;
  17. }
  18.  
  19. //modifier method for userGuess (should call random number method)
  20. public void setGuess(int guess) {
  21. userGuess = guess;
  22. }
  23.  
  24. //accessor method for userGuess
  25. public int getLoc() {
  26. return prizeLoc;
  27. }
  28. //accessor method for prizeLoc
  29. public int getGuess() {
  30. return userGuess;
  31. }
  32. //method to generate random number between 1 & 3
  33. int random = (int)(Math.random() * 3 + 1);
  34.  
  35. //method to reveal the door
  36. public int getRandom() {
  37. return random;
  38. }
  39.  
  40. //method to update user's guess
  41. public int updateGuess() {
  42. userGuess = newGuess;
  43.  
  44. //toString method
  45. public String toString() {
  46. return "user guess: " + userGuess + " prizeLoc: " + prizeLoc;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement