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 that overrides the string computed properties defined in the Animal
class to provide the appropriate values for a dog:
public class Dog: Animal { public override var spelledSound1: String { get { return "Woof" } } public override var spelledSound2: String { get { return "Wooooof" } } public override var spelledSound3: String { get { return "Grr" } } public override var danceCharacters: String { get { return "/-\\ \\-\\ /-/" } } }
With just a few additional lines of code, we will create another subclass of Animal
, which is a Frog
class that also overrides the string's read-only properties defined in the Animal
class to provide the...