Solution (source code)

= Solution

Two mechanisms are \b[<subtype polymorphism> and <parametric polymorphism>].

With <subtype polymorphism>, a <trait> or <abstract class> declares an operation and concrete subclasses implement or override it. A `Player` reference holding a `House` object invokes `House.play` through <dynamic dispatch>. The client is written against the common contract.

With <parametric polymorphism>, a <software class> or <generic method> has a <type parameter>, such as `List[T]` or `def identity[T](x: T): T = x`. The same definition works for many supplied <type arguments>, with static relationships between input and output types. <Method overloading> is another mechanism, usually called <ad hoc polymorphism>: alternatives share a name but are selected from their parameter signatures at compile time.