|
Review of conditionals and looping
| ||
|
1. Consider this program fragment and picture Jeroo bob = new
Jeroo(); |
![]() |
Where will bob be after this part of the program executes? a. in the net |
|
2. Consider this program fragment and picture Jeroo bob = new
Jeroo(); |
![]() |
Where will bob be after this part of the program executes? a. in the net |
|
What mistake did the person make on #2
| ||
|
3. Consider this program fragment and picture Jeroo bob = new
Jeroo(); |
![]() |
Why does bob not gather all the flowers? a. he does gather all the flowers |
|
4. Consider this program fragment and picture Jeroo bob = new
Jeroo(); |
![]() |
How many flowers does bob pick? a. 8 |
| What is the difference between if( ) and while ( ) ? | ||
|
6. Consider this program fragment and picture Jeroo bob = new
Jeroo(); |
![]() |
a. How many flowers will bob pick up ? b. Will bob stop when he reaches the net?
|
|
7. Would this code have worked the same if we had done this? while(bob.isClear(AHEAD)) | ||
|
8. Consider this program fragment and picture Jeroo bob = new Jeroo(0,2,
SOUTH); |
![]() |
bob does not move to the end of the water. which of these conditional should be added to the while loop a. if(bob.isClear(RIGHT)) { bob.hop(); } b. if(bob.isClear(RIGHT)) { bob.hop(2); } c. if(bob.isWater(LEFT)) { bob.hop(2); } |
| 9. What is the difference between the coding fragments on the right. They are part of a Jeroo method | while(isClear(AHEAD)) { hop(); } |
if(isClear(AHEAD)) { hop(); } |
| 10. What is the difference between the coding fragments on the right. They are part of a Jeroo method | if(isClear(AHEAD)) { hop(); } else { plant(); } |
if(isClear(AHEAD)) { hop(); } plant(); |
| 11. When will these conditionals be TRUE |
a. b. |
c. if(!bob.isClear(AHEAD)) d. if(!bob.isNet(RIGHT))
|