Skip to content

Instantly share code, notes, and snippets.

@jonnycaley
Last active December 30, 2020 11:15
Show Gist options
  • Save jonnycaley/d85fe4d8b198e4f33c59a4276aeed6c8 to your computer and use it in GitHub Desktop.
Save jonnycaley/d85fe4d8b198e4f33c59a4276aeed6c8 to your computer and use it in GitHub Desktop.
interface Vehicle {
fun getAveragePrice(): Int
fun calculateCost(): Money
fun calculateDailyMaintanence(): Money
}
class VehicleFactory() {
fun makeVehicle(type: VehicleType): Vehicle {
when (type) {
is CAR -> {
return Car()
}
is MOTORBIKE -> {
return Motorbike()
}
is VAN -> {
return Van()
}
is LORRY -> {
return Lorry()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment