收集總數
Collect the Total
這個關卡會自動以亂數決定寶石的數量 (randomNumberOfGems
),然後我們要寫程式收集剛好這個數量的寶石。
let totalGems = randomNumberOfGems
// 變數初始化
var gems = 0
// 還沒收集夠就繼續走
while gems < totalGems {
walkAlongLeft {
if isOnGem {
collectGem()
gems += 1
}
}
}
Last updated
Was this helpful?