In this lab, you will program two sprites to gossip.
On this page, you will experiment with an existing program as an introduction to the project.
DISPLAY(gossip())if it's written as text or if it's shown as blocks.
You won't have to be able to write code in this notation on the AP exam. You just have to be able to read it so you can answer questions about it.
In the Settings menu (), choose "Zoom blocks...", and adjust the slider.
Abstraction is the most fundamental idea in computer science, but it's hard to define until you've seen some examples. The most basic kind of abstraction is to give a name to something in a program. For example, here we gave the name who
to the idea "pick an item at random from this list of people (or cats)." This is called procedural abstraction because we use a procedure (a block) to name the idea. This makes your code readable. You'll see other kinds of abstraction later.
If you find yourself wanting to copy and paste code from one place to another without changing it, then give it a name (open a Block Editor and paste the code there) and call your procedure in both places. If you discover later on that you need to fix a bug in this code, you only have to change it once instead of finding every copy throughout your program.
broadcast
does.who2
compares to who
and how gossip2
compares to gossip
.
The broadcast
block sends a message to all the sprites. To set the message, click the down arrow and select "new..."
For more information about the when I receive
block, right-click (or control-click on a Mac) the block and select "help..."