title: How to check more than one condition in a method and do something based on it's return value
body: <p>I am currently trying to work on a project that includes creating a BankAccount system. This system allows you to create a new bank account where you state who it belongs to, the balance, etc. </p>
  
  <p>One of the methods is being able to withdraw money from the account. As well as this, you are able to check if the account has an overdraft or not.</p>
  
  <p>For the <code>withdraw</code> method, I have to meet several conditions. These are the following:</p>
  
  <ul>
  <li>The Value must be above 0.0, meaning that withdrawals of below 0 won't happen</li>
  <li>The balance must NOT go below 0.0, UNLESS if the account HAS an overdraft.</li>
  </ul>
  
  <p>At the moment, I have been able to make it so the method will return false, if the amount is below 0.0. This is shown below:</p>
  
  <pre><code>public boolean withdraw (double amount) {
      if (hasOverdraft) {
          this.balance -= amount;
          return true;
      } else if (amount &gt; 0.0) {
          this.balance -= amount;
          return true;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>However, I have tried several different things to make it work with the overdraft but can't seem to do it.</p>
  
  <p>Bear in mind that at the end, the method needs to be able to:</p>
  
  <ul>
  <li>Allow the user to withdraw money providing the amount is above 0.0</li>
  <li>Allow the user to go into their overdraft (e.g. -100), PROVIDING that they actually have an overdraft.</li>
  </ul>
  
  <p>The overdraft can  be checked with the following code:</p>
  
  <pre><code>if (hasOverdraft)
  </code></pre>
  
  <p>To check the code is working, we are using the following code:</p>
  
  <pre><code>public static void main (String[] args) {
      BankAccount lewis = new BankAccount("1234", "Lewis", false);
      System.out.println(lewis);
  
      lewis.setBalance(200);
      System.out.println(lewis);
      lewis.withdraw(250);
      System.out.println(lewis);
  }
  </code></pre>
  
  <p>The "false" for BankAccount is showing that the account doesn't have an overdraft. We will test it with both false and true.</p>