Exercise on classes in Scala