View Javadoc

1   package net.trajano.twiff.sample.component;
2   
3   import java.io.Serializable;
4   import java.util.Random;
5   
6   /***
7    * This class wraps the number to guess.
8    * 
9    * @author Archimedes Trajano
10   */
11  public final class NumberToGuess implements Serializable {
12      /***
13       * The randomizer.
14       */
15      private Random random = new Random();
16  
17      /***
18       * The number to guess.
19       */
20      private int number;
21  
22      /***
23       * Constructs the number to guess.
24       */
25      public NumberToGuess() {
26          newRandom();
27      }
28  
29      /***
30       * Gets the number to guess.
31       * 
32       * @return the number to guess.
33       */
34      public int getNumber() {
35          return number;
36      }
37  
38      /***
39       * Sets a new random number to guess.
40       */
41      public void newRandom() {
42          number = random.nextInt(20) + 1;
43      }
44  }