Question
Classes: BankAccount: -balance , customer Customer(conncted to bankaccount): -name , id ChequingAccount: -overdraftFee, overdraftAmount Additional information: 1)The instance variable overdraftAmount should be moved from BankAccount
Classes:
BankAccount:
-balance , customer
Customer(conncted to bankaccount):
-name , id
ChequingAccount:
-overdraftFee, overdraftAmount
Additional information:
1)The instance variable overdraftAmount should be moved from BankAccount to ChequingAccount. The withdraw method in BankAccount should ensure the balance is never below zero.
2)The method transfer in BankAccount should transfer specified amount from the account the method is invoked on to the account provided as an argument. The method should do this by invoking the withdraw and deposit methods.
3)The method setBalance in BankAccount should have protected access so child classes can access it. It should do not do any error checking (and it should allow a negative balance.)
4)ChequingAccount overrides the withdraw method such that it allows an overdraft of at most overdraftAmount. (The balance is allowed to be negative.) If the withdraw results in an overdraft (the balance in the account is negative), the customer should be charged the overdraftFee. (The charge is done by reducing the account balance by the overdraftFee amount.)
I need help tracing this java code on paper! Thank you
Customer c = new Customer ("John Doe", 321); BankAccount b1 = new BankAccount (c, 100.0); cheguingAccount b2 = new CheguingAccount (c, 200.0, 12.0); b2.setOverdraftAmount (150.0); BankAccount b3 = b2; System.out.println (bl.getBalance ()+", " + b3.getBalance O) b1.withdraw (110); System.out.printin (b1.getBalance )+","+ b3.getBalance )) b2.withdraw (300.0) System.out.println (b1.getBalance )+","+ b3.getBalance ()); bl.transfer (50.0, b2) System.out.println (bl.getBalance )+","+ b3.getBalance ()) b2.transfer (88, bl) System.out.println (bl.getBalance ()+", " + b3.getBalance ))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started