Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- A bank account has a balance that can be changed by
- deposits and withdrawals.
- */
- public class BankAccount
- {
- public BankAccount()
- {
- /*Raph's Nutty Notes
- * This is your constructor Method. When calling this Method, everything inside of these brackets are immediately written into
- * The Bank Account starts at 0
- */
- balance = 0;
- }
- public BankAccount(double initialBalance)
- {
- balance = initialBalance;
- }
- public void deposit(double amount)
- {
- //Raph's Nutty Notes . . When we deposit, the amount is added upon the account balance
- balance = balance + amount;
- }
- public void withdraw(double amount)
- {
- /*Raph's Nutty Notes
- * When withdrawing the amount is subtracted from the balance
- */
- balance = balance - amount;
- }
- public void addInterest(double interest){
- balance = balance + (balance*interest);
- }
- public double getBalance()
- {
- /*Raph's Nutty Notes
- *just your typical Getter method
- */
- return balance;
- }
- private double balance;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement