FileDocCategorySizeDatePackage
Account.javaAPI DocExample1382Tue Mar 20 16:26:14 GMT 2001None

Account.java

public class Account
   {
     private double the_balance     =0.0d; //current balance of account
     private double the_min_balance =0.0d; //minimum balance(overdraft)

     public Account()                           // constructor
        {
          the_balance = the_min_balance = 0.00; //initialise new account balance
        }
     
     public double getAccountBalance()   // a method that will return account balance
        {
          return the_balance;
        }

     public double withdraw( final double money ) // method to handle withdrawal
        {
          if (the_balance - money >= the_min_balance)
            {
              the_balance = the_balance - money;
              return money;
            }
           else
            {
              return 0.00;
            }
         }

      public void deposit(final double money) // method to make a deposit
         {
          the_balance = the_balance + money;
         }
 }


/* class TestAccount
   {
    public static void main(String[] args)
     {
       Account george = new Account();
       george.deposit(100.00);
       System.out.println("Current balance for George is :" + george.getAccountBalance());
       george.withdraw(50.00);
       System.out.println("Current balance for George is :" + george.getAccountBalance());
      } 
    } */