Last active
January 19, 2018 06:40
-
-
Save agoiabel/f456c3cc0162c4ce2f6dc272d98d35a7 to your computer and use it in GitHub Desktop.
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
| protocol Blendable { | |
| func blend() -> () | |
| } | |
| class Fruit: Blendable { | |
| var name: String | |
| init(name: String) { | |
| self.name = name | |
| } | |
| func blend() { | |
| print("Almost all friut can be used") | |
| } | |
| } | |
| class Dairy { | |
| var name: String | |
| init(name: String) { | |
| self.name = name | |
| } | |
| } | |
| class Cheese: Dairy { | |
| //we cannot use cheese to make smoothie | |
| //so no blendable protocol implemented | |
| } | |
| class Milk: Dairy, Blendable { | |
| func blend() { | |
| print("Milk is a type of dairy") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment