Class Notes (1,100,000)
CA (620,000)
U of A (10,000)
CMPUT (90)
Lecture 7

CMPUT 101 Lecture 7: active-learning.pdf


Department
Computing Science
Course Code
CMPUT101
Professor
Marianne Kerolus
Lecture
7

This preview shows page 1. to view the full 4 pages of the document.
CMPUT 101 2013
Active Learning 1
Consider the following BeeperBot program that runs under auxiliary mode.
1 . d e f i n e main {
2 . while( ha s be ep er ( 0 ) ) {
3 . move beeper ( 0 , 1 )
4 . }
5 . while (next to a beeper) {
6. pick beeper
7 . move beeper ( 0 , 2 )
8 . }
#How many b e epe rs ar e i n bag2 a f t e r the while loop e x i t s ?
#P le as e check with your TA b e f o r e p ro ce ed in g .
9 . while( ha s be ep er ( 1 ) ) {
1 0 . move beeper ( 1 , 0 )
1 1 . p ut b ee pe r
1 2 . move
1 3 . }
14. turn left
15. turn left
1 6 . move
1 7 . next
1 8 . }
1 9. d e f i n e next {
2 0 . wh il e ( h as b eep er ( 2 ) ) {
2 1 . move beeper ( 2 , 0 )
2 2 . p ut b ee pe r
2 3 . wh il e (next to a beeper) {
2 4 . d e s t r o y b e e p e r
2 5 . }
2 6 . move
2 7 . }
2 8 . }
1
You're Reading a Preview

Unlock to view full version