Skip to content

Instantly share code, notes, and snippets.

@jonnycaley
Last active April 24, 2020 15:02
Show Gist options
  • Save jonnycaley/a7d258a799e8c94b12132d54b34dbcb9 to your computer and use it in GitHub Desktop.
Save jonnycaley/a7d258a799e8c94b12132d54b34dbcb9 to your computer and use it in GitHub Desktop.
fun calculateCost(vehicle: Vehicle): Money {
return when (vehicle) {
is CAR -> {
CalculateCarCost(vehicle)
}
is MOTORBIKE -> {
CalculateMotorbikeCost(vehicle)
}
is VAN -> {
CalculateVanCost(vehicle)
}
is LORRY -> {
CalculateLorryCost(vehicle)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment