scala/ScalaBook/chapter-02/lemons.scala

class Fruit {
  def price() = 0.5
}

trait gustation {
  def taste(): String = {
    return "sour"
  }
}

class Lemon extends Fruit with gustation {
  override def price() = 0.2
  def color() = "yellow"
}


def worth(f:Fruit)=f.price()

var l = new Lemon()
println("----------->Lemons")
println("price: "+l.price()+" color: "+l.color())

println("taste: "+l.taste())
var f = new Fruit()

f=l
println("----------->Fruits")
println("price: "+f.price())
println(worth(f))