我试图连接两个类。我有一个CarType
课,另一个Cars
。
当我在Cars
注册汽车时,我希望该汽车从CarType
类连接到汽车类型。
这些是我的课程
class CarType {
var brand: String?
var speed: Int?
var fuel: Int?
var serviceProvider: String?
init(brand: String, speed: Int, fuel: Int, serviceProvider: String) {
self.brand = brand
self.speed = speed
self.fuel = fuel
self.serviceProvider = serviceProvider
}
}
class Cars {
var regNum: String?
var nextMaint: String?
var operatedBy: String?
init(regNum: String, nextMaint: String, operatedBy: String) {
self.regNum = regNum
self.nextMaint = nextMaint
self.operatedBy = operatedBy
}
}
我试图继承CarType
中的Cars
,但这让我很困惑......