Suppose, you are implementing “Overdraft Account (OD)” class using java for a banking app. An OD type account is opened with an approved loan limit (ex 100000/-). The account holder can deposit any amount of money in the OD account at any time. S/he can draw an amount of money from the account (acn) until sufficient acn balance. S/he allowed to draw money beyond his/her acn balance if the total over-drawing amount remains within the loan limit. A java sketch for OD acn is given bellow & code is expected to run in multi-threading mode. (same code with run by different counter in the blank)
Code:
public class ODAccount extends BankAccount {
double limit;
public void ODAccount (double setLimit) {
$this->balance= 0; //super class has balance property
$this->limit= setLimit;
}
public void depositMoney (double deposit Amount) {
balance= balance+ depositAmount;
public void drawMoney (double drawAmount) throws ODLimit Exceeded {
if (balance – drawAmount>=-1*limit)
balance= balance- drawAmount;
else throw new OD Limit Exceeded ();
}
}