11.5 Initializing the Subclass
As the SavingsAccount class currently stands, it inherits the init initializer method from the parent BankAccount class which was implemented as follows:
init(number: Int, balance: Float)
{
accountNumber = number
accountBalance = balance
}
Clearly this method takes the necessary steps to initialize both the account number and balance properties of the class. The SavingsAccount class, however, contains an additional property in the form of the interest rate variable. The SavingsAccount class, therefore, needs its own initializer to ensure that the interestRate property is initialized when instances of the class are created. This method can perform this task and then make a call to the init method of the parent class to complete the initialization of the remaining variables:
class SavingsAccount: BankAccount {
...