CodeMonkey過關學習筆記系列:120-128關
•”布爾邏輯” 歌劇( BOOLEAN OPERA ) 120~135
第 關挑戰
until tiger.sleeping()
wait()
goto banana
第 關挑戰
until bear.sleeping()
wait()
goto banana
第 關挑戰
for b in bananas
until bear.sleeping()
wait() //#等待,什麼?
goto b
第 關挑戰
until bear.sleeping() and tiger.sleeping()
wait()
goto banana
第 關挑戰
until bear.sleeping() and tiger.sleeping()
wait()
goto banana
第 關挑戰
until bear.sleeping() and tiger.sleeping() //#并且...
wait()
for b in bananas
goto b
第 關挑戰
for b in bananas
until bear.sleeping() and tiger.sleeping() //#并且...
wait()
if b.green()
goat.goto b
monkey.goto b
第 關挑戰
waitForSafety = () ->
until bear.sleeping() and tiger.sleeping()
wait()
for b in bananas
waitForSafety()
goto b
第 關挑戰
for b in bananas
until bear.sleeping() and tiger.sleeping()
wait()
if b.frozen()
goat.goto b
goat.hit()
until bear.sleeping() and tiger.sleeping()
wait()
monkey.goto b
CodeMonkey過關學習筆記系列:129-135關
•”布爾邏輯” 歌劇( BOOLEAN OPERA ) 120~135
第 關挑戰
until tiger.sleeping() or tiger.playing()
wait()
goto banana
第 關挑戰
或者 or 指令能夠讓小猴等到許多個判斷式其中之一的條件成立了之後,就開始下個行動.
until tiger.sleeping() or tiger.playing()
wait()
goto banana
第 關挑戰
//你可以在所有的判斷式裡面都使用 或者 or 指令
until tiger.sleeping() or tiger.playing()
wait()
step
//#這裡等待 <code>wait</code> 熊玩耍或睡着
until bear.sleeping() or bear.playing()
wait()
step
第 關挑戰
until bear.playing() or bear.sleeping()
wait()
goat.goto banana
第 關挑戰
for b in bananas
until tiger.playing() or tiger.sleeping()
wait()
if b.green()
goat.goto b
else
monkey.goto b
第 關挑戰
for b in bears
until b.sleeping() or b.playing()
wait()
step
第 關挑戰
waitFor = (t) ->
until t.sleeping() or t.playing()
wait()
for t in tigers
for stepper in [monkey, goat]
waitFor t
stepper.step
CodeMonkey過關學習筆記系列:136-141關
•”不是”我的茶( NOT MY CUP OF TEA ) 136~141
第 關挑戰
//這個開始是否邏輯了。
//not 這個否定指令會把原先是 肯定yes 的結果變成 否定no 的結果。此外,它也會把原先就 否定的no 結果變成 yes 的結果.
if not banana.green()
//#你隻能修改這裡的代碼:
goto banana
第 關挑戰
請試試看使用 爛掉的 rotten() 來識别爛掉的香蕉并且不要靠近它們!
rotten英 [ˈrɒtn] 美 [ˈrɑ:tn] adj.腐爛的;惡臭的;堕落的;極壞的
for b in bananas
turnTo b
if b.rotten()
say "Yuck!"
else
goto b
第 關挑戰
goto bush
goto bananas[]
第 關挑戰
if not banana.rotten()
goto banana
第 關挑戰
for b in bananas
#修複這裡的條件:
if not b.rotten()
goto b
第 關挑戰
for b in bananas
if not b.rotten()
goto b
goto bush