So far, we have created many protocols for our animals. Some of these protocols inherit from other protocols; therefore, we have a protocol hierarchy tree. Now, it is time to combine class inheritance with protocol inheritance to recreate our animal classes.
The following lines show the new version of the Animal
class that conforms to the AbstractAnimal
protocol:
public class Animal: AbstractAnimal {
public class var numberOfLegs: Int {
get {
return 0;
}
}
public class var averageNumberOfChildren: Int {
get {
return 0;
}
}
public class var abilityToFly: Bool {
get {
return false;
}
}
public var age: Int
init(age : Int) {
self.age = age
print("Animal created")
}
public class func printALeg() {
preconditionFailure("The pringALeg method must be overriden")
}
public...