ch 4 logical structures in alice

Post on 28-Nov-2014

2.220 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

An Introduction to Programming with Alice

Logic StructuresLogic Structuresin Alice 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

Logic and control tiles

If/Else LoopWhile

Logic and Control TilesLogic and Control Tiles

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.

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.

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.

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.

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.

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.

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.

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.

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.

top related