Last active
April 15, 2018 06:06
-
-
Save LH17/165fe4d2803d2cf66e8f3e99c1d79214 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
// protocol for creating a product | |
protocol ShoeShop { | |
func produceShoe() | |
} | |
// class that conforms to ShoeShop protocol | |
class Nike: ShoeShop { | |
func produceShoe() { | |
print("Shoe Produced") | |
} | |
} | |
// class that is initialsed with the object that conforms to ShoeShop protocol | |
class Director { | |
let shoeShop: ShoeShop | |
// instantiation | |
init(shoeShop: ShoeShop) { | |
self.shoeShop = shoeShop | |
} | |
func produce() { | |
shoeShop.produceShoe() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment