Question:
(a) To be considered object-oriented(OO), a language should support abstraction, encapsulation, inheritance and polymorphism.
Explain briefly each of the terms in bold font.
(b) What do you understand by "instantiating an object"?
(c) A bank account has two pieces of data - a password and a balance, and as actions to act on that data, it allows a user to create account, make deposits, make withdrawals, and to check the balance.
Deposit is used to add cash to the account. It simply increments Balance by the amount of the deposit. Withdraw is used to remove cash from the account. However, it needs to be a bit selective. First it checks to see if the password passed in matches the initial password. It also checks to ensure that the amount requested to be withdrawn is available in the account. If it passes these two conditions, then Balance is decremented by the amount of the withdrawal. GetBalance checks the password and then returns balance.
Write a script which has four methods to act on the bank data: new, mDeposit, mWithdraw, and mGetBalance.
(d) (i) Give three advantages of using Parent scripts in place of globals.
(ii) Give three disadvantages of using Parent scripts in place of globals.