ch 4 logical structures in alice

14
An Introduction to Programming with Alice Logic Structures Logic Structures in Alice in Alice

Upload: chaffey-college

Post on 28-Nov-2014

2.220 views

Category:

Documents


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Ch 4 logical structures in alice

An Introduction to Programming with Alice

Logic StructuresLogic Structuresin Alice in Alice

Page 2: Ch 4 logical structures in alice

Logic and Control TilesLogic and Control Tiles

Logic and Logic and control tiles control tiles are located at are located at the bottom of the bottom of the editor areathe editor area

Page 3: Ch 4 logical structures in alice

Logic and control tiles

Page 4: Ch 4 logical structures in alice

If/Else LoopWhile

Page 5: Ch 4 logical structures in alice

Logic and Control TilesLogic and Control Tiles

Page 6: Ch 4 logical structures in alice

If/Else TileIf/Else Tile

A blank If/Else tile has a place for A blank If/Else tile has a place for a true or false condition, and a true or false condition, and places for two instructions or sets places for two instructions or sets of instructions.of instructions.

Page 7: Ch 4 logical structures in alice

If/Else: Binary BypassIf/Else: Binary Bypass

A binary bypass has A binary bypass has no instruction after no instruction after the word the word Else.Else.

Page 8: Ch 4 logical structures in alice

If/Else: Binary ChoiceIf/Else: Binary Choice

A binary choice has A binary choice has an instruction after an instruction after the word the word If If and after and after the word the word Else.Else.

Page 9: Ch 4 logical structures in alice

The Loop TileThe Loop Tile

The Loop tile is used for simple count The Loop tile is used for simple count controlled loops. controlled loops.

Page 10: Ch 4 logical structures in alice

The Loop TileThe Loop Tile

The complicated view of the Loop tile The complicated view of the Loop tile provides access to the loop control provides access to the loop control variable, called the index.variable, called the index.

Page 11: Ch 4 logical structures in alice

The Loop TileThe Loop Tile

It can then be used inside instruction tiles in It can then be used inside instruction tiles in the body of the loop. the body of the loop.

In this example, the height the Cheshire Cat In this example, the height the Cheshire Cat jumps will be equal to the index.jumps will be equal to the index.

Page 12: Ch 4 logical structures in alice

The While TileThe While Tile

A blank While tile has a place for a A blank While tile has a place for a true or false condition, and a true or false condition, and a place for an instruction or set of place for an instruction or set of instructions to be repeated.instructions to be repeated.

Page 13: Ch 4 logical structures in alice

The While TileThe While Tile

The While tile can be used for sentinel loops The While tile can be used for sentinel loops that are not count-controlled. that are not count-controlled.

Here the loop will continue until the skater is Here the loop will continue until the skater is within 3 meters of the flagpole.within 3 meters of the flagpole.

Page 14: Ch 4 logical structures in alice

The While TileThe While Tile

The while tile can also be used to build The while tile can also be used to build count-controlled loops.count-controlled loops.