Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. /**
  2.    A bank account has a balance that can be changed by
  3.    deposits and withdrawals.
  4. */
  5. public class BankAccount
  6. {
  7.    public BankAccount()
  8.    {
  9.     /*Raph's Nutty Notes
  10.     *   This is your constructor Method. When calling this Method, everything inside of these brackets are immediately written into
  11.     *   The Bank Account starts at 0
  12.     */
  13.       balance = 0;
  14.    }
  15.  
  16.    public BankAccount(double initialBalance)
  17.    {
  18.       balance = initialBalance;
  19.    }
  20.  
  21.    public void deposit(double amount)
  22.    {
  23.     //Raph's Nutty Notes . . When we deposit, the amount is added upon the account balance
  24.       balance = balance + amount;
  25.  
  26.    }
  27.  
  28.    public void withdraw(double amount)
  29.    {
  30.     /*Raph's Nutty Notes
  31.     *   When withdrawing the amount is subtracted from the balance
  32.     */
  33.       balance = balance - amount;
  34.    }
  35.    
  36.    public void addInterest(double interest){
  37.         balance = balance + (balance*interest);
  38.    }
  39.  
  40.    public double getBalance()
  41.    {
  42.     /*Raph's Nutty Notes
  43.      *just your typical Getter method
  44.      */
  45.       return balance;
  46.    }
  47.  
  48.    private double balance;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement