Declaring subclasses that inherit the conformance to protocols
We have an Animal
class that conforms to both the AnimalProtocol
and Equatable
protocols. Now, we will create a subclass of Animal
, a Dog
class, which overrides the string computed properties defined in the Animal
class to provide the appropriate values for a dog. The code file for the sample is included in the swift_3_oop_chapter_06_03
folder:
open class Dog: Animal { open override var spelledSound1: String { get { return "Woof" } } open override var spelledSound2: String { get { return "Wooooof" } } open override var spelledSound3: String { get { return "Grr" } } open override var danceCharacters: String { get { return "/-\\ \\-\\ /-/" ...