//20190401031杨小可//练习5structBasketballPlayer{
var name: Stringvar threePointShot: Intvar twoPointShot: Intvar score: Int {
get {
return2*twoPointShot+3*threePointShot
}
}
mutatingfuncshot(point: Int) {
if point == 3 {
threePointShot += 1
} elseif point == 2 {
twoPointShot += 1
}
}
funcdescription() {
print("Player \(name) has \(threePointShot) three point shot and \(twoPointShot) two point shot, the total socre is \(score)")
}
}
var player = BasketballPlayer(name: "YaoMing", threePointShot: 0, twoPointShot: 0)
player.name = "YaoMing"
player.description()
player.shot(point: 2)
player.shot(point: 2)
player.shot(point: 3)
player.shot(point: 2)
player.shot(point: 2)
player.description()