10.7 Initializing and De-initializing a Class Instance
A class will often need to perform some initialization tasks at the point of creation. These tasks can be implemented by placing an init method within the class. In the case of the BankAccount class, it would be useful to be able to initialize the account number and balance properties with values when a new class instance is created. To achieve this, the init method could be written in the class as follows:
class BankAccount {
var accountBalance: Float = 0
var accountNumber: Int = 0
init(number: Int, balance: Float)
{
accountNumber = number
accountBalance = balance
}
func displayBalance()
{
...