Computer Science Course of Study (WA)

 

Decision Making

Page history last edited by vic 1 yr ago

Decision Making

 

Decision Making is where the computer decides to do nothing, something or something else.

 

If Then decision making

 

In the most simplest case the computer decides to do something or nothing. In the example shown below, the computer detects the level of sound coming into a microphone attached to the computer. If it is above a set level, then the sprite moves according to the instructions.

 

 

This is a great program with little kids!!

 

Exercises

1. Create a program that make the sprite dance - use left, right, up and down arrow keys. (Hint: Use "key right arrow pressed?" and "key left arrow pressed?")

2. Create a "tennis" game where a ball is bounced off the sprite and the walls.

 

If Then Else decision making

 

This is the case where the computer decides to do one set of statements or another set of statements.

 

In the statements below, the sprite goes about drawing a simple image until it comes in contact with the mouse pointer. Then it goes off to the centre of the drawing board and starts again.

 

 

Exercises

1. Write a program that plays simple melody or a drum beat depending on what sprite the mouse pointer is touching.

2

3

 

Comments (0)

You don't have permission to comment on this page.