class Rectangle{
var origin = Point()
var sie = Size()
var center :point{
let centerX = origin.x+size.width/2
let centrY = origin.y+size.height/2
return Point(x:centerX,y:CenterY)
} //依賴其它屬性存在的屬性。Center根據origin和Size推算
}
var origin = Point()
var sie = Size()
var center :point{
let centerX = origin.x+size.width/2
let centrY = origin.y+size.height/2
return Point(x:centerX,y:CenterY)
} //依賴其它屬性存在的屬性。Center根據origin和Size推算
}
2016-10-16
結構體:值類型,數值較多的時候使用結構時使用。 簡單的一類數據,輕量級。效率更加高效
類: 描述的物體類型,可以使用類??梢宰鳛樽诸惖某橄箢?對多種事物提供工廠模式,時使用。 可以選擇型為物體指定協議。 擴展時定義。 復雜數據
類: 描述的物體類型,可以使用類??梢宰鳛樽诸惖某橄箢?對多種事物提供工廠模式,時使用。 可以選擇型為物體指定協議。 擴展時定義。 復雜數據
2016-10-16
switch中結構體的地位
Array,Dictionary set ,String
Int,Float,Double,Bool,String 都屬于結構體
ege:
Int a:Int=1
a.distanceTo(100)
按住鍵盤option 點擊a,點擊command 方法名或者類名
Array,Dictionary set ,String
Int,Float,Double,Bool,String 都屬于結構體
ege:
Int a:Int=1
a.distanceTo(100)
按住鍵盤option 點擊a,點擊command 方法名或者類名
2016-10-16
Array 和Dictionary Set在switch中屬于結構體類型,值類型。 賦值給另外一個變量拷貝。
字符串String 屬于一個結構
字符串String 屬于一個結構
2016-10-16
struct 結構體中可以定義函數
結構體中也可以定義函數
enum shape {
case sure (side :double)
case rectangle(width:double,height:double)
fun area()->Dounble{
switch self { //可以將在外面定義個switch方法移動到結構體內部。
case ...
case ...
}
}
}
結構體中也可以定義函數
enum shape {
case sure (side :double)
case rectangle(width:double,height:double)
fun area()->Dounble{
switch self { //可以將在外面定義個switch方法移動到結構體內部。
case ...
case ...
}
}
}
2016-10-16
public static let defaultManager = GameManager()
private init(){
}
private init(){
}
2016-10-16