import Foundation
class TV {
var name:String="TV"
func getMyTVKeys()->Int{
return 12;
}
}
//@final使得子类中无法重写
class MITV:TV {
override var name:String{
get{
return self.name
}
set{
if(self.name=="barry"){
super.name="barry's father"
}else{
super.name="hello"
}
}
}
override func getMyTVKeys() -> Int {
return 24;
}
func getMyTVKeys(name:String)->Int{
return 36;
}
}
var mymiTV=MITV()
println(mymiTV.name)
mymiTV.name="xiaomi"
println(mymiTV.name)
println(mymiTV.getMyTVKeys())
println(mymiTV.getMyTVKeys("nihao"))