Hi, I wanted to created a java file base on the given javadoc below. I am currently stuck on the embezzle method. First, i don't understand what's the "BankAccount" in 'public void embezzle(BankAccount other)' do or is. Second, How can i add funds from the other account to the other account? Do i need to created a second bankaccount within the same class to achieve this? Please help...Any comments on it would be greatly appreciated.
Class BankAccount
Object
extended by pre1.BankAccount
public class BankAccount
extends Object
This class models a bank account, which has a balance and an interest rate.
Constructor Summary
BankAccount(double balance, double interestRate)
Create a new BankAccount with the given balance and interest rate.
Method Summary
void accrueInterest()
Earn interest on the current balance and deposit the earnings back into the account.
void deposit(double amount)
Deposit an amount of money into the bank account.
void embezzle(BankAccount other)
Withdraw all of the funds from another account (other), and deposit them in the current one.
double getBalance()
Get the current balance of the bank account.
void withdraw(double amount)
Withdraw an amount of money from the bank account.
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
BankAccount
public BankAccount(double balance,
double interestRate)
Create a new BankAccount with the given balance and interest rate.
Parameters:
balance - The balance of the new bank account
interestRate - The interest rate of the new bank account
Method Detail
accrueInterest
public void accrueInterest()
Earn interest on the current balance and deposit the earnings back into the account.
deposit
public void deposit(double amount)
Deposit an amount of money into the bank account.
Parameters:
ammount - The amount of money to be deposited
embezzle
public void embezzle(BankAccount other)
Withdraw all of the funds from another account (other), and deposit them in the current one.
Parameters:
other - The account from which to withdraw all the funds.
getBalance
public double getBalance()
Get the current balance of the bank account.
Returns:
The account's current balance
withdraw
public void withdraw(double amount)
Withdraw an amount of money from the bank account.
Parameters:
amount - The amount of money to be withdrawn