17.3 A Kotlin Inheritance Example
As with most programming concepts, the subject of inheritance in Kotlin is perhaps best illustrated with an example. In “The Basics of Object Oriented Programming in Kotlin” we created a class named BankAccount designed to hold a bank account number and corresponding current balance. The BankAccount class contained both properties and methods. A simplified declaration for this class is reproduced below and will be used for the basis of the subclassing example in this chapter:
class BankAccount {
var accountNumber = 0
var accountBalance = 0.0
constructor(number: Int, balance: Double) {
accountNumber = number
accountBalance = balance
}
...