How do I make new SavingAccount with init values for owner and balance
open class BankAccount(val owner: String = "Long John Silver", private var balance: Double = 0.00) {
constructor (amount: Double) : this() {
this.balance = amount
}
fun deposit(amount: Double){
this.balance += amount
}
fun withdraw(amount: Double){
this.balance -= amount
}
fun getBalance(): Double{
return this.balance
}
}
And the child class
class SavingAccount(val increasedBy: Double = 0.05): BankAccount(){
fun addInterest(): Unit{
val increasedBy = (this.getBalance() * increasedBy)
deposit(amount = increasedBy)
}
}
and in main
fun main(args: Array<String>) {
val sa = SavingAccount();// how to do this SavingAccount("Captain Flint", 20.00)
println(sa.owner)
println(sa.owner)
}
How can I create SavingAccount for a new user, without default values?