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

what's the "BankAccount" in 'public void embezzle(BankAccount other)'

'BankAccount' is the type of the arg passed to the method. To call the method, you must use a variable that refers to a BankAccount object.

Second, How can i add funds from the other account to the other account?

To move funds from one account to another: you need to do a withdrawal from the source account and an addFunds to the target account.

Be sure to use code tags when posting your code. See icon above to right of text input area.

Edited 6 Years Ago by NormR1: n/a

This question has already been answered. Start a new discussion instead.