Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Deal
- {
- //instance variables
- private int prizeLoc;
- private int userGuess;
- //constructor
- public Deal()
- {
- setPrizeLoc();
- setUserGuess();
- }
- //modifier method for prizeLoc (should call random number method)
- public void setLoc(int loc) {
- prizeLoc = loc;
- }
- //modifier method for userGuess (should call random number method)
- public void setGuess(int guess) {
- userGuess = guess;
- }
- //accessor method for userGuess
- public int getLoc() {
- return prizeLoc;
- }
- //accessor method for prizeLoc
- public int getGuess() {
- return userGuess;
- }
- //method to generate random number between 1 & 3
- int random = (int)(Math.random() * 3 + 1);
- //method to reveal the door
- public int getRandom() {
- return random;
- }
- //method to update user's guess
- public int updateGuess() {
- userGuess = newGuess;
- //toString method
- public String toString() {
- return "user guess: " + userGuess + " prizeLoc: " + prizeLoc;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement