CodeMonkey过关学习笔记系列:142-150关
•”比来比去” ( COMPARISONS ) 142~150
第 142 关挑战
say health()
goto banana
第 143 关挑战
goto bananas[0]
goto bananas[1]
第 144 关挑战
if health() == 40 //#是的,40等于40,得到yes
goto banana
if health() == 100 //#不是,40不是100,得到no
goto banana
第 145 关挑战
请待在 休息区 healthZone 以便恢复体力l.
goto healthZone
//#修改这里,它永远到不到1000的数值
until health() == 100
wait()
goto banana
第 146 关挑战
for b in bananas
goto healthZone
//#在这里等待,直到小猴的健康值是100
until health() == 100
wait()
goto b
第 147 关挑战
goto healthZone
until health() ==100
wait()
goto banana
第 148 关挑战
请使用 小于 < 符号来比较是否一个数值小于另外一个数值.
if health() < 90 #是的,80小于90,得到yes
goto banana
else
goto banana
第 149 关挑战
for b in bananas
goto b
//#提示: 如果健康值低于70,就需要补充体力啦
if health() <=70
goto healthZone
until health()==100
wait()
第 150 关挑战
gotoNearestHealth = () ->
d0 = distanceTo healthZones[0]
d1 = distanceTo healthZones[1]
if d0 < d1
goto healthZones[0]
else
goto healthZones[1]
for b in bananas
goto b
if health() < 60
gotoNearestHealth()
#在这里等待,直到小猴是健康的!
until health() ==100
wait()