Created
May 7, 2023 14:55
-
-
Save o-nnerb/ff925462a163f314cac20a93e8caa676 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
class Animal { | |
func makeNoise() { | |
print("Unknown animal!") | |
} | |
} | |
class Dog: Animal { | |
override func makeNoise() { | |
print("The dog goes woof!") | |
} | |
} | |
class Cat: Animal { | |
override func makeNoise() { | |
print("The cat goes meow!") | |
} | |
} | |
class Bird: Animal { | |
override func makeNoise() { | |
print("The bird goes tweet!") | |
} | |
} | |
func makeNoise(animal: Animal) { | |
animal.makeNoise() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment