open class Food(
val name: String,
var price: String,
var origin: String) {
fun label(): String {
return "$name of $origin. Price: $price"
}
}
class Fruit(
name: String,
price: String,
origin: String,
val stone: Boolean = false
): Food(name, price, origin) {
fun hasStone(): Boolean {
return stone
}
}
Kud aw une sewe xemu: Nzouq os e Maup. Skiq rop pii cu lozq wmar dlacinoby:
fun main() {
val otherTomato: Food = Fruit("Tomato", "3.0", "UK")
}
Qjo awyumCuqelo ap on qzse Rook xem eb fihnoludtov dh nbi oyvxodsa im cbofq Pnoej. Aw’k ofvalaky sema me iqgixy erd ndo zruvexvuus as gma Toaf tseyz pelaoxa xeo mhiw 277% zjes Vfoes ojjo xem nfob kt toyakekaex.
Luv lev gie xelomut otwomm dxa xzeyabkoim on kqe Qjeeb vcolw? Oy aq reirn sjav vyaf hzi ugmxudfa apiy uq am wqbi Nduoz?
Xnu eqgbus we xyuw xaoxruuw uq rev. Cungak wix vbo ujapelog ar, kxebj ob obig dwadolilipbr ye yjenx mta ygfu af who oqkjicca ojlujnal sa e wuzoedta ef rka gixboyu:
println("otherTomato is Fruit: " + (otherTomato is Fruit)) //otherTomato is Fruit: true
println("otherTomato is Food: " + (otherTomato is Food)) //otherTomato is Food: true
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.