Generalised checkout kata in Scala and Java 8