class Frutas(color:String, sabor:String, precio:Int, frescura:Int){
var color:String = “”
var sabor:String = “”
var precio:Int = 0
var frescura:Int = 0
init{
this.color = color
this.sabor = sabor
this.precio = precio
this.frescura = frescura
}
fun pudrirse():Int{
println(“La fruta se está pudriendo”)
this.frescura = this.frescura – 20
// println(“La fruta tiene ${this.frescura}% de frescura”)
return frescura
}
fun fresco(){
var p = pudrirse()
println(“La fruta tiene ${p} % de frescura”)
}
}
fun main(args: Array<String>) {
var manzana = Frutas(“Rojo”,”Dulce”,4,100)
println(manzana.color)
manzana.pudrirse()
manzana.fresco()
manzana.fresco()
manzana.fresco()
}
Report
There was a problem reporting this post.
Block Member?
Please confirm you want to block this member.
You will no longer be able to:
See blocked member's posts
Mention this member in posts
Invite this member to groups
Message this member
Add this member as a connection
Please note:
This action will also remove this member from your connections and send a report to the site admin.
Please allow a few minutes for this process to complete.