title: Java - A simple (to everyone but me) method - Inheritance
body: <p>Ok, so I hope you can all help, I have been tasked whilst tying to learn the language with the age-old test of simple savings account and checking account using inheritence.</p>
  
  <p>My problem is, I want to make the checking account incapable of going over its overdraft limit and the savings account incapable of going below 0 but cant work out how? my code so far is as follows:</p>
  
  <p><strong>SUPERCLASS (BankAccount):</strong></p>
  
  <pre><code>public class BankAccount
      {
          protected String CustomerName;
          protected String AccountNumber;
          protected float Balance;
  
  
  //Constructor Methods
  
   public BankAccount(String CustomerNameIn, String AccountNumberIn, float BalanceIn)
          {
              CustomerName = CustomerNameIn;
              AccountNumber = AccountNumberIn;
              Balance = BalanceIn;
  
          }
  
        // Get  name
        public String getCustomerName()
          {
              return (CustomerName);
          }
  
        // Get account number
        public String getAccountNumber()
          {
              return (AccountNumber);
          }
  
         public float getBalance()
          {
              return (Balance);
          }
  
  
          public void Withdraw(float WithdrawAmountIn)
         {  
             if(WithdrawAmountIn &lt; 0)
                  System.out.println("Sorry, you can not withdraw a negative amount, if you wish to withdraw money please use the withdraw method");
             else
                  Balance = Balance - WithdrawAmountIn;
         }
  
          public void Deposit(float DepositAmountIn)
         {
             if(DepositAmountIn &lt; 0)
                  System.out.println("Sorry, you can not deposit a negative amount, if you wish to withdraw money please use the withdraw method");
             else 
             Balance = Balance + DepositAmountIn;
         }
  
  
      } // End Class BankDetails
  </code></pre>
  
  <p><strong>SUBCLASS (SavingsAccount):</strong></p>
  
  <pre><code>public class SavingsAccount extends BankAccount
    {   
  
        private float Interest;
  
        public SavingsAccount(String CustomerNameIn, String AccountNumberIn, float InterestIn, float BalanceIn)
          {
              super (CustomerNameIn, AccountNumberIn, BalanceIn);
              Interest = InterestIn;
          }
  
  
        public float getInterestAmount()
         {
             return (Interest);
         }
  
        public float newBalanceWithInterest()
         {  
             Balance = (getBalance() + (getBalance()  * Interest / 100) );
  
             return (Balance);
         }
  
         public void SavingsOverdraft()
         {
              if( Balance &lt; 0)
                  System.out.println("Sorry, this account is not permitted to have an overdraft facility");
         }
  
     }
  </code></pre>
  
  <p><strong>SUBCLASS (CheckingAccount):</strong></p>
  
  <pre><code>public class CheckingAccount extends BankAccount
    {
        private float Overdraft;
  
  
        public CheckingAccount(String CustomerNameIn, String AccountNumberIn, float BalanceIn, float OverdraftIn)
          {
  
              super (CustomerNameIn, AccountNumberIn, BalanceIn);
  
              Overdraft = OverdraftIn;
          }
  
         public float getOverdraftAmount()
         {
             return(Overdraft);
         }
  
        public void setOverdraft()
          {
              if (Balance &lt; Overdraft)
                  System.out.println("Sorry, the overdraft facility on this account cannot exceed £100");
  
         }
      }
  </code></pre>
  
  <p>Thank you very very much for any advice and help!</p>