class example { //parent class
var one:Int = 10 //i want all subclass variableOne to be added to this
var two:Int = 20 //i want all subclass variableTwo to be added to this
init () {
}
}
class subClassOne : example { //subclass one
var variableOne:Int = 30 //properties i want to add to parent properties
var variableTwo:Int = 30 //properties i want to add to parent properties
override init () {
super.init ()
super.one = one + variableOne
super.two = two + variableTwo
}
}
class subClassTwo {
var variableOne:Int = 20 //properties i want to add to parent properties
var variableTwo:Int = 20 //properties i want to add to parent properties
override init () {
super.init ()
super.one = one + variableOne
super.two = two + variableTwo
}
}
我希望将所有子类variableOne添加到父类属性1
我还希望将所有子类variableTwo添加到父类2