17.4 Extending the Functionality of a Subclass
So far we have been able to create a subclass that contains all the functionality of the parent class. In order for this exercise to make sense, however, we now need to extend the subclass so that it has the features we need to make it useful for storing savings account information. To do this, we simply add the properties and methods that provide the new functionality, just as we would for any other class we might wish to create:
class SavingsAccount : BankAccount {
var interestRate: Double = 0.0
constructor(accountNumber: Int, accountBalance: Double) :
super(accountNumber, accountBalance)
fun calculateInterest(): Double
...