Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaeetutorial.guessnumber;
- import java.io.Serializable;
- import java.util.Random;
- import java.util.logging.Logger;
- import javax.faces.bean.SessionScoped;
- import javax.inject.Named;
- @Named
- @SessionScoped
- public class UserNumberBean implements Serializable {
- private static final long serialVersionUID = 5443351151396868724L;
- private static final Logger log = Logger.getLogger(UserNumberBean.class.getName());
- Integer randomInt = null;
- Integer userNumber = null;
- String response = null;
- private int maximum = 10;
- private int minimum = 0;
- public UserNumberBean() {
- Random randomGR = new Random();
- randomInt = randomGR.nextInt(maximum + 1);
- log.info(randomInt.toString());
- }
- public void setUserNumber(Integer user_number) {
- userNumber = user_number;
- }
- public Integer getUserNumber() {
- return userNumber;
- }
- public String getResponse() {
- if ((userNumber == null) || (userNumber.compareTo(randomInt) != 0)) {
- return "Sorry, " + userNumber + " is incorrect.";
- } else {
- return "Yay! You got it!";
- }
- }
- public int getMaximum() {
- return (this.maximum);
- }
- public void setMaximum(int maximum) {
- this.maximum = maximum;
- }
- public int getMinimum() {
- return (this.minimum);
- }
- public void setMinimum(int minimum) {
- this.minimum = minimum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment