Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume the existence of a BankAccount class with a method, getAvailable that ret

ID: 3656239 • Letter: A

Question

Assume the existence of a BankAccount class with a method, getAvailable that returns the amount of available funcs in the account (as an integer), and a subclass, OverdraftedAccount, with two integer instance variables: overdraftLimit that represents the amount of money the account holder can borrow from the account (i.e., the amount the account balance can go negative), and overdraftAmount, the amount of money already borrowed against the account. Override the getAvailable method in OverdraftedAccount to return the amount of funcds available (as returned by the getAvailable method of the BankAccount class) plus the overdraftLimit minus the overdraftAmount.

Explanation / Answer

public class OverdraftedAccount extends BankAccount { private int overdraftLimit; private int overdraftAmount; public OverdraftedAccount() { super(); //Calling default constructor of superclass i.e, BankAccount overdraftLimit = 100;// It can be any value. overdraftAmount = 0; } public OverdraftedAccount(int limit, int amount) { super(); //Calling default constructor of superclass i.e, BankAccount overdraftLimit = limit; overdraftAmount = amount; } @Override public int getAvailable() { return super.getAvailable() + overdraftLimit - overdraftAmount; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote