import UIKit //class Animal { // func speak() { // print("Animal speak") // } // subscript(index: Int) -> Int { // return index // } //} // //var anim: Animal //anim = Animal() //anim.speak() //print(anim[6]) // //class Cat: Animal { // override func speak() { // print("Cat speak") // } // // override subscript(index: Int) -> Int { // return super[index] + 1 // } //} // //var cat = Cat() //cat.speak() //print(cat[6]) class Animal { class func speak() { print("Animal speak") } static subscript(index: Int) -> Int { return index } } class Cat: Animal { override class func speak() { super.speak() print("Cat speak") } } class Circle { static var radius: Int = 0 class var diameter: Int { set { print("Circle setDiameter") radius = newValue / 2 } get { print("Circle getDiameter") return radius * 2 } } } class SubCircle: Circle { override class var diameter: Int { set { print("SubCircle setDiameter") super.diameter = newValue > 0 ? newValue : 0 } get { print("SubCircle getDiameter") return super.diameter } } }