SHARE
TWEET

APCS2012_C3X1_BankAccount.java

calcpage Sep 28th, 2012 140 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //BankAccount.java      MrG     2012.0925
  2. public class BankAccount
  3. {
  4.         private double myBalance;
  5.  
  6.         /**
  7.         Constructor: initializing myBalance
  8.         */
  9.         public BankAccount()
  10.         {
  11.                 myBalance = 0;
  12.         }
  13.  
  14.         /**
  15.         Accessor: shows myBalance
  16.         @return myBalance
  17.         */
  18.         public double getBalance()
  19.         {
  20.                 return myBalance;
  21.         }
  22.  
  23.         /**
  24.         Mutator: adds money to account
  25.         @param amount is the money being added
  26.         */
  27.         public void deposit(double amount)
  28.         {
  29.                 myBalance = myBalance + amount;
  30.         }
  31.  
  32.         /**
  33.         Mutator: subtracts money from account
  34.         @param amount is the money being subtracted
  35.         */
  36.         public void withdraw(double amount)
  37.         {
  38.                 myBalance = myBalance - amount;
  39.         }
  40. }
RAW Paste Data
Top