Last active
December 30, 2020 11:15
-
-
Save jonnycaley/d85fe4d8b198e4f33c59a4276aeed6c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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