title: extract water and refill water tank
body: <p>I wrote a class Watertank and now I want to write a short loop (10-times) test programm which extracts water (empty water tank 0 liter) and than refills the tank back to 5000.</p>
  
  <p><strong>I.)</strong> I created a private member variable "water" double with 5000 (liter).
  <strong>II.)</strong> Public getter member method "getWater" which returns the actual value of the member variable "water".
  <strong>II.II)</strong> Public setter member method "setWater"
  <strong>III.)</strong> Public member method "extractWater" which extracts 200 liter from the tank and returns a boolean.
  "TRUE" if the tank is NOT empty, "FALSE" when the tank is empty.
  <strong>IV.)</strong> Public member method "refillWater" which sets the member variable "water" to its original value.</p>
  
  <p><a href="https://i.imgur.com/CcLFwhW.png" rel="nofollow noreferrer">https://i.imgur.com/CcLFwhW.png</a></p>
  
  <p>Update:</p>
  
  <p>I fixed my code and added the logic.
  It seems to work, can someone review the logic, codingstyle and tell me if I worked properly regarding object orientation. I feel like my code is redundant at certain parts.</p>
  
  <pre><code>public class Watertank {
  private double water = 5000;
  
  public double getWater() {
      return water;
  }
  
  public void setWater(double water) {
      this.water = water;
  }
  
  public boolean extractWater() {
  
      if ((water &lt;= 5000) &amp;&amp; (water &gt;= 200)) {
          water -= 200;
          return true;
      }
      return false;
  
  
  }
  
  public double refillWater() {
      water = 5000;
  
      return 0;
  }
  
  
  public static void main(String[] args) {
  
  
      Watertank vWater = new Watertank();
      for (int i = 0; i &lt; 10; i++) {
          while (vWater.water &gt;= 0) {
              vWater.extractWater();
              System.out.println(vWater.water);
              if (vWater.water == 0) {
                  vWater.refillWater();
                  break;
              }
  
  
          }
  
  
      }
  }
  }
  </code></pre>