Читать книгу Programming Kotlin Applications - Бретт Мак-Лахлин, Brett McLaughlin - Страница 87
LISTING 2.10: A much simpler version of Person
Оглавлениеpackage org.wiley.kotlin.person class Person(_firstName: String, _lastName: String, _height: Double, _age: Int, _hasPartner: Boolean) { var firstName: String = _firstName var lastName: String = _lastName var height: Double = _height var age: Int = _age var hasPartner: Boolean = _hasPartner fun fullName(): String { return "$firstName $lastName" } override fun toString(): String { return fullName() } }
Compile and then run PersonApp
and you should get correct results—both before and after updating the last name for the rose
instance.