Consider the provided BankAccount
class and its access control levels:
public, protected, and private.
Your task is to implement the withdraw
method and the
sufficient_funds?
method in the BankAccount
class.
The withdraw
method should adjust the account balance by subtracting
the withdrawal amount if there are sufficient funds as determined by the
sufficient_funds?
method. Make the withdraw
method a protected
method, restricting direct access from outside the class.
The sufficient_funds?
method should return a boolean value based on
whether the account has sufficient funds for the intended withdrawal.
Define the sufficient_funds?
method as private to restrict its access
to the object's context only.
Additionally, you need to define a secondary withdraw
method in the
SavingsAccount
class, allowing a withdrawal of up to $1000
at a time.