title: if / else if inside getter/setter Java
body: <p>I recently started my education Software Engineering where we are currently learning the basics of Java... we have to create a simple text-based airport game and i ran into a little trouble.</p>
  
  <p>I already tried google and the SOF search function and found many "solutions" however; none seem to fix my problem. so forgive me for my "noob" qeustion :P</p>
  
  <p>In the game we have several airports that generates a random amount of passengers each round, with a minimum of 100 and a maximum of 999. To do this i used the following code... which works and doesnt give me any errors but i still get random results below 100. What am i doing wrong? like i said i tried many different ways but it seems to neglect my if / if else conditions...</p>
  
  <pre><code>int paxGenerator;
  
  public int getPaxGenerator() {
      return this.paxGenerator = (int) (Math.random() * 1000);
  
  }
  
  public void setPaxGenerator(int paxGenerator) {
  
      if (paxGenerator&lt;100) {
          this.paxGenerator = 100;
      } else if (paxGenerator &gt; 999) {
          this.paxGenerator = 999;
      }
  
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p><code>return this.paxGenerator = (int) (Math.random() * 900) + 100;</code> does indeed fix my problem, thx @user43219 However, for the sake of learning; can someone give me an example of how i should correctly implement an if else statement? Because i want to create 12 new objects, that all have to generate a different random number. if i place the random code outside the getter/setters it gives me the same number everytime... and the if else statement isnt even allowed outside the getter/setters... bear in mind im a beginner so things arent that obvious to me :P thx in advance!</p>