Jeroo Chapters 1C (Loops), 1D (If) & 1E (Conditionals/Boolean)

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

repetition

A loop is also known as a ________________________ structure. (all lower case)

A

After executing the code below, which of the following statements would be required to pass a flower to the next Jeroo? if( hero.isJeroo(AHEAD) ) a. hero.give(AHEAD); b. hero.plant( ); c. hero.give( ); d. hero.give(HERE) e. hero.hop(AHEAD)

OR (must be in ALL CAPS)

Another name for disjunction is?

E

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method below is executed? method test101( ) { if(!(!isWater(LEFT))) { hop(24); } else hop(16); }

B

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method below is executed? method test108( ) { if(!isClear(HERE)) { hop(4); } else hop(16); }

Jeroo is dead from hitting the other Jeroo at the end of the course

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method below is executed? method test114( ) { if (!(isJeroo(RIGHT))) { if (!(isWater(HERE))) { hop(23); } else { hop(3); } else { hop(9); } } }

B

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method below is executed? method test118( ) { if (isWater(AHEAD)) { if (!(isClear(RIGHT))) { hop(12); } else { hop(16); } else { hop(4); } } }

A

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method below is executed? method test66() { if( isNet(RIGHT) ) { hop(4); } }

A; Jeroo will not move because "isClear(HERE)" is false. The Jeroo itself is "here".

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method below is executed? method test68( ) { if(isClear(HERE)) { hop(8); } }

B

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method below is executed? method test74( ) { if (!(isJeroo(RIGHT))) { hop(4); } }

E

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method below is executed? method what() { if( !( isNet(LEFT) ) ) { hop(16); } }

A

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method what() below is executed. method what() { while( isClear(LEFT) ) { hop(); } }

D

Based on the island pictured, at which point will the Jeroo at (1,0) stop if the method what() below is executed. method what() { while(!(isNet(RIGHT))) { hop(); } }

C

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { if ( !(isWater(LEFT) || isNet(RIGHT)) ) { hop(4); } }

B

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { if (!(!isWater(LEFT) || isNet(RIGHT))) { hop(10); } else { hop(3); hop(); } }

E

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { if(isClear(AHEAD) || isNet(RIGHT)) { hop(20); } }

B

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while ( !(!isWater(RIGHT) || isNet(LEFT)) ) { hop(4); } }

Facing Jeroo

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while ( !(isJeroo(AHEAD) && isClear(LEFT)) ) { hop(); } }

Will end directly in front of and facing the other Jeroo; must process the clearRIGHT and clearLEFT, then the NOT.

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while( !(isClear(RIGHT) && isClear(LEFT)) ) { hop(4); } }

D

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while( !isClear(AHEAD) || !isNet(RIGHT) ) { hop(); } }

B

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while( isWater(RIGHT) ) { hop(4); } }

On top of flower. A Jeroo can sit on top of a flower without the program crashing or killing the Jeroo.

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while(!(isFlower(HERE))) { hop(); } }

B

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while(!(isJeroo(RIGHT))) { hop(); } }

Jeroo will hop until he lands on the other Jeroo at which time he will "die". Two Jeroos cannot occupy the same space.

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while(!isClear(HERE)) { hop(); } }

A

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while(isClear(RIGHT)) { hop(); } }

C

Based on the island pictured, which point will the Jeroo at (1,0) will stop at if the method below is executed. method what() { while( !(isWater(LEFT) || isNet(RIGHT)) ) { hop(); } }

1 (isFacing)

How many Jeroo sensor methods require compass direction as a parameter? What are they?

1 (hasFlower)

How many Jeroo sensor methods require no parameters? What are they?

5 (isFlower, isJeroo, isNet, isWater, isClear)

How many Jeroo sensor methods require relative direction as a parameter? What are they?

6

How many different sensor methods are there in Jeroo?

4

How many sensor methods are based on directions in relation to the Jeroo?

2

How many ways can a selection structure branch in Jeroo?

boolean

Sensor methods are also known as _______________ methods.

FALSE

True/False Negation is another name for AND

FALSE; isClear requires a relative direction NOT a compass direction

True/False The code below has no compile errors: if ( isClear(EAST) ) { turn(LEFT); }

True

True/False The code below has no compile errors: if( isJeroo(HERE) ) { turn(RIGHT); }

TRUE

True/False The code below has no compile errors: method what() { while( isWater(HERE) ) { turn(LEFT); } }

True; HERE is a relative direction even if it does not make sense in this situation. So code is valid, but the Jeroo will not actually do anything

True/False The code below is valid. if( isJeroo(RIGHT) ) { turn(HERE); }

False; do not need to pick unless there is a flower ahead, water not being ahead does not indicate a flower is present

True/False The code below works properly. method pick24() { while(!isWater(AHEAD)) { hop(); pick(); } }

FALSE; isFlower cannot have "west" as it's direction & direction needs to be in all caps; pick and hop should begin with jerry. since the while statement uses jerry.

True/False The following code does not have any compile errors: while( jerry.isFlower(west) ) { pick(); hop(); }

False; isFlower requires a relational direction in the parenthesis, not a compass direction

True/False The following code is written properly. while( jerry.isFlower(WEST) ) { pick(); hop(); }

TRUE

True/False The symbols || are used to express disjunction.

FALSE, there is a ; at the end of the method what()

True/False: The code below has no compile errors: method what(); { while(!isWater(AHEAD)) { hop(); pick(); } }

FALSE

True/False: Sensor methods can only be used in while loops.

!

What is the symbol for negation?

&&

What symbol(s) is used to express AND?

B

What types of loops can we use in Jeroo? A. for B. while C. do D. all of the above E. more than one of the above

E; EAST must be in all caps for this sensor method to be valid; isJeroo must have a relative direction (AHEAD, RIGHT, LEFT, HERE)

Which of these is not a valid call to a valid sensor method? a. isFacing(East) b. isJeroo(WEST) c. isNet(AHEAD) d. isJeroo(EAST) e. more than one correct answer

F, isFacing compass direction must be in ALL CAPS and isJeroo must have a relative direction not a compass direction

Which of these is not a valid sensor method? a. isFacing(East) b. isJeroo(WEST) c. isNet(AHEAD) d. isJeroo(EAST) e. isJeroo(NORTH) f. more than one of the above


Ensembles d'études connexes

Therapeutic Exercise Elbow Chapter 18

View Set

AP World History Modern: Chapter 17

View Set

Semester 2 Exam Review Questions

View Set

Chapter 3 Licensing and Certification

View Set