Solution (source code)

= Solution

A <mixin> is reusable behavior supplied by a <trait> and composed into a <class in object-oriented programming>. Scala allows only one direct superclass, so <mixins> allow several independently reusable capabilities without multiple concrete-class inheritance. A <trait> can provide implemented methods and require abstract members from its host class.

``
trait Named {
  def name: String
}
trait Greeting extends Named {
  def greeting: String = "Welcome, " + name
}
class Account(val name: String)
class WelcomedAccount(name: String) extends Account(name) with Greeting

val example = new WelcomedAccount("reader")
assert(example.greeting == "Welcome, reader")
``

Here the single superclass supplies `name`, and the <mixin> supplies the derived greeting. The same behavior can be mixed into another unrelated host that satisfies `Named`. <Mixin> composition uses a defined linearization and requires incompatible concrete member conflicts to be resolved; it does not make arbitrary combinations of concrete superclasses legal.<Class Composition with Mixins in the Scala documentation>[A class has one superclass and can include several traits]{ref}