//: [Previous](@previous)
import Foundation
class Animal {
var gender: String
init(gender: String){
self.gender = gender
}
}
class Dog: Animal {
var name: String
var color: String
var size: Int
init(name: String, color: String, size: Int, gender: String){
self.name = name
self.color = color
self.size = size
super.init(gender: gender)
}
}
class Cat: Animal {
var name: String
var color: String
var size: Int
init(name: String, color: String, size: Int, gender: String){
self.name = name
self.color = color
self.size = size
super.init(gender: gender)
}
}
//: [Next](@next)
var myAnimal = [Animal]()
myAnimal.append(Dog(name: "Doggi", color: "Red", size: 3, gender: "man"))
myAnimal.append(Dog(name: "Sharik", color: "Write", size: 4, gender: "man"))
myAnimal.append(Dog(name: "Bobik", color: "Black", size: 5, gender: "man"))
myAnimal.append(Cat(name: "Fandorin", color: "Black", size: 3, gender: "man"))
var myAnimalTwo = [Animal]()
myAnimalTwo.append(Dog(name: "Doggi", color: "Red", size: 3, gender: "man"))
myAnimalTwo.append(Dog(name: "Sharik", color: "Write", size: 4, gender: "man"))
myAnimalTwo.append(Dog(name: "Bobik", color: "Black", size: 5, gender: "man"))
myAnimalTwo.append(Cat(name: "Mysya", color: "Black", size: 3, gender: "man"))
var animalAny = [AnyObject]()
for item in myAnimal{
animalAny.append(item)
}
for i in myAnimal{
switch i {
case _ as Dog:
print(i)
default:
print("The end!")
}
}