Class demo
main.swift
let padX1 = iPadX()
println("\(padX1.id)")
println("\(padX1.type)")
println("\(padX1.capacity)")
println("\(padX1.xRate)")
let padX2 = iPadX(newXType:"iPadX mini", newXCapacity:32)
println("\(padX2.id)")
println("\(padX2.type)")
println("\(padX2.capacity)")
println("\(padX2.xRate)")
===================================================================
class iPad
{
let id:String
var type:String
var capacity:Integer
init(){
let UUID:NSUUID = NSUUID.UUID()
let stringId:String = UUID.UUIDString
self.id = stringId
self.type=""
self.capacity=0
}
init(newType: String, newCapacity:Integer) {
let UUID:NSUUID = NSUUID.UUID()
let stringId:String = UUID.UUIDString
self.id = stringId
self.type = newType
self.capacity = newCapacity
}
}
===================================================================
class iPadX : iPad
{
var xRate:Integer
init(){
xRate = 10
super.init()
}
init(newXType:String, newXCapacity:Integer){
xRate = 10
super.init(newType:newXType, newCapacity:newXCapacity)
}
}
沒有留言:
張貼留言