Last active
September 7, 2017 14:21
-
-
Save caseykulm/fa926f97983dbdb5d41b00ce2207f38e to your computer and use it in GitHub Desktop.
Inject Functions: 2
This file contains hidden or 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 TreatFactory { | |
fun getTreats(): Treats | |
} | |
class Petco: TreatFactory { | |
fun getTreats(): Treats { | |
// Details of how to get to Petco, | |
// what aisle the treats are on, | |
// what treats they carry that doggo | |
// likes, etc. | |
} | |
} | |
data class DoggoStash( | |
val leash: Leash, | |
val waterBowl: WaterBowl, | |
val bed: Bed, | |
val treatFactory: TreatFactory) | |
fun proceedOnRoadTrip(doggoStash: DoggoStash) { | |
getDoggoLeashedUp(doggoStash.leash) | |
packupWaterBowl(doggoStash.waterBowl) | |
setupBedInBackSeat(doggoStash.bed) | |
startDriving() | |
stopForTreats(doggoStash.treatFactory) | |
} | |
val leash = DoggoLeash() | |
val waterBowl = WaterBowl() | |
val bed = Bed() | |
val treatFactory = Petco() | |
val doggoStash = DoggoStash(leash, waterBowl, bed, treatFactory) | |
proceedOnRoadTrip(doggoStash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment