<< Chapter < Page Chapter >> Page >

Repetitively clicking the mouse in the Stage area causes the Counter variable to count down in increments of oneand causes the counter variable to count down in increments of five.

Event-driven programming

The ability to write programs that cause certain operations to occur in response to events (such as pressing the space bar and clicking the mouse on the Stage) is often referred to as event-driven programming.

It is easy to write event-driven programs in Scratch. On the other hand, writing event-driven programs is not so easy in languages such asJava, C#, and C++. You need quite a lot of programming knowledge to write event-driven programs in those languages.

It is useful to give programming students a taste of event-driven programming early, if for no other reason than the factthat it tends to make programming more interesting.

Example blocks with pointed ends

The blocks shown in Image 4 are not used in this program. They are shown in this module to illustrate blocks with pointed endsreferred to earlier .

Image 4. example blocks with pointed ends.

Missing image.
Image 4. Example blocks with pointed ends.

Run the program

I encourage you to use the information provided above along with the Scratch 2.0 programming interface shown in Image 1 to write and run this program. Experiment with the code, making changes, and observing the results of yourchanges. Make certain that you can explain why your changes behave as they do.

A copy of this program has been posted online for your review.

I also encourage you to write the programs described below.

Student programming projects

The following projects are designed to:

  • Help the student retain the knowledge gained by studying the module.
  • Require the student to think beyond the material presented in the module by requiring the student to answer the question "How do I ...?"

Project 1

Begin with the program named Variable01 and modify it to create a new program named Variable02 . Modify the original program in such a way that pressing the space bar five times in succession, (after clicking the green flag to set both variables to zero) , will cause the displayed values of the variables named Counter and counter to be as shown in Image 5 .

Image 5. output from project 1.

Missing image.
Image 5. Output from Project 1.

Having reached that point, clicking the mouse five times in succession in the Stage area will cause the displayed values of the variables named Counter and counter to be as shown in Image 6 .

Image 6. output from project 1.

missing image
Image 6. Output from Project 1.

A copy of this program is posted online for your review.

Project 2

You should successfully complete Project 1 before attempting this project. Begin with the program named Variable01 and modify it to create a new program named Variable03 . Modify the original program in such a way that pressing the space bar five timesin succession, (after clicking the green flag to set both variables to zero) , will cause the displayed values of the variables named Counter and counter to be as shown in Image 7 .

Image 7. output from project 2.

Missing image.
Image 7. Output from Project 2.

Questions & Answers

microeconomics deals with individuals and firms while macroeconomics deal with the activities of the society in large
C-Stixxs Reply
Morning guys I need questions under any topic in economics
C-Stixxs
what is your question
Shalom
why Economics is science
Fixed Reply
Ok
Olamilekan
what is economic
Arome Reply
is a science which studies human behavior as a relationship with ends n scarce which have alternative uses
C-Stixxs
Explain four reason why scale of preference is necessery
Afusat Reply
What's a perfectly elastic demand
jessica Reply
what is the perfect elasticity of demand
Beltus
what is a balance budget
Azayi Reply
balance budget is when the expenses ND tax re equal
Joseph
it is when expenditure and revenue are equal
C-Stixxs
types of cost curves
Lonwabo Reply
there are different types Average total cost curve (ATC) Average Variable cost curve (AVC) Marginal cost curve (MC) .......... and so on
C-Stixxs
what is histogram
Stella Reply
What is the reason for demand
Taye Reply
hello good afternoon
sheriffvandy Reply
Hi
Tahira
hello
Divakar
hello
Shekerusegun
what is production possibility curve
Amina Reply
A curve that shows different combinations (amount) of two goods with a production of limited resources (it is based on the Scarcity principle)
Minalu
How demand and supply are related
Alimamy Reply
The law of demand states that "all other being equal ",the higher the price the lower the commodity and the lower the price the higher the commodity of purchase within a given period of time .
Emmanuel Reply
participants in market
LEHLOGONOLO Reply
do you have questions of cerculer flow
Pink
do the negative slope of production possibility curve sloped to show trade offs in production of two goods?
Bafokeng Reply
l need the law of demand
Gifty
The law of demand stated that all other things been equal the high the price the high the quantity demanded and vase visa
Amina
The Law of Demand states that ceteris Parabus" The higher the price of the commodity the lower the quantity demanded and the lower the price of the commodity the higher the quantity demanded.
Paul
A soccer field is a rectangle 130 meters wide and 110 meters long. The coach asks players to run from one corner to the other corner diagonally across. What is that distance, to the nearest tenths place.
Kimberly Reply
Jeannette has $5 and $10 bills in her wallet. The number of fives is three more than six times the number of tens. Let t represent the number of tens. Write an expression for the number of fives.
August Reply
What is the expressiin for seven less than four times the number of nickels
Leonardo Reply
How do i figure this problem out.
how do you translate this in Algebraic Expressions
linda Reply
why surface tension is zero at critical temperature
Shanjida
I think if critical temperature denote high temperature then a liquid stats boils that time the water stats to evaporate so some moles of h2o to up and due to high temp the bonding break they have low density so it can be a reason
s.
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
Crystal Reply
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Chris Reply
Difference between extinct and extici spicies
Amanpreet Reply
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Teaching beginners to code. OpenStax CNX. May 27, 2013 Download for free at http://cnx.org/content/col11498/1.20
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?

Ask