thufir

Untitled

Sep 28th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. package javaeetutorial.guessnumber;
  2.  
  3. import java.io.Serializable;
  4. import java.util.Random;
  5. import java.util.logging.Logger;
  6. import javax.faces.bean.SessionScoped;
  7. import javax.inject.Named;
  8.  
  9. @Named
  10. @SessionScoped
  11. public class UserNumberBean implements Serializable {
  12.  
  13.     private static final long serialVersionUID = 5443351151396868724L;
  14.     private static final Logger log = Logger.getLogger(UserNumberBean.class.getName());
  15.     Integer randomInt = null;
  16.     Integer userNumber = null;
  17.     String response = null;
  18.     private int maximum = 10;
  19.     private int minimum = 0;
  20.  
  21.     public UserNumberBean() {
  22.         Random randomGR = new Random();
  23.         randomInt = randomGR.nextInt(maximum + 1);
  24.         log.info(randomInt.toString());
  25.     }
  26.  
  27.     public void setUserNumber(Integer user_number) {
  28.         userNumber = user_number;
  29.     }
  30.  
  31.     public Integer getUserNumber() {
  32.         return userNumber;
  33.     }
  34.  
  35.     public String getResponse() {
  36.  
  37.         if ((userNumber == null) || (userNumber.compareTo(randomInt) != 0)) {
  38.             return "Sorry, " + userNumber + " is incorrect.";
  39.         } else {
  40.             return "Yay! You got it!";
  41.         }
  42.     }
  43.  
  44.     public int getMaximum() {
  45.         return (this.maximum);
  46.     }
  47.  
  48.     public void setMaximum(int maximum) {
  49.         this.maximum = maximum;
  50.     }
  51.  
  52.     public int getMinimum() {
  53.         return (this.minimum);
  54.     }
  55.  
  56.     public void setMinimum(int minimum) {
  57.         this.minimum = minimum;
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment