Ashutosh Panda
12/10/2019, 7:48 AMclass book(){
var pages:Int=300
}
class puppy(b: book)
{
fun removePages():Int=b.pages-Random().nextInt(0,100)
}
fun book.getWeight():Double=pages*1.5
val hamlet=book()
val puppy=puppy(hamlet)
fun book.CountPages(i:Int):Int=pages-i
println("${hamlet.CountPages(20) } \n")
println("${hamlet.getWeight()} \n")
println("${puppy.removePages()+hamlet.CountPages(20)}")
Ivan Kubyshkin [JetBrains]
12/10/2019, 7:50 AMclass puppy(val b: book)
Matthieu Esnault
12/10/2019, 7:51 AMb
is provided to the constructor, but it’s not a property of the class puppy
.
try
class puppy(val b: book)
Edit : too slow :)Ashutosh Panda
12/10/2019, 8:19 AMIvan Kubyshkin [JetBrains]
12/10/2019, 8:48 AMRandom.nextInt(0,100)