Unit 3 Lesson 11 bubble 11

This is my 2nd year teaching CS Discoveries and I use the exemplars to help but really want to understand why the following code make the pear stop growing? I get the set.animation to change to a pear, not how to make it stop growing. Thanks in advance!!

if (fruit.scale > 2) {
fruit.setAnimation(“pear”);
} else {
fruit.scale = fruit.scale + 0.01;
}

fruit.scale = fruit.scale + 0.01;
if (fruit.scale > 2) {
fruit.setAnimation(“pear”);
fruit.scale = fruit.scale - 0.01;
}
This is the code that I used to make the pear stop growing.

Awwww, that makes more sense and my students actually just put fruit scale = 2.1 in and it also stops pear from growing!!!

Thank you so much! Lauri

1 Like