Chapter 1 Introduction to Alice and Objects Starting

Chapter 1: Introduction to Alice and Objects Starting Out with Alice: A Visual Introduction to Programming Third Edition

1. 1 What is a Computer Program? • Computer is a device that follows instructions for manipulating and storing information. • How does the computer get those instructions? • A computer program is a set of instructions that the computer follows to perform a task. 1 -2

1. 1 What is a Computer Program? • Program • Set of instructions; carefully written so that they follow a logical sequence Steps are called an ALGORITHM • When the computer performs those instructions, the computer is running or executing a program. 1 -3

1. 2 Algorithms and Programming Languages • Algorithm • Set of well-defined logical steps • Must be performed in order to perform a task • Example…making a cup of instant coffee: – – – – Remove lid from coffee jar Put lid down on counter Remove 1 tsp of coffee from jar Place that coffee in a cup Add 8 oz of boiling water to cup Use teaspoon to stir water and coffee mixture Stir 10 revolutions Remove teaspoon from cup and place on counter Is this adequate? Is it detailed enough? Is there anything ambiguous in what is written? 1 -4

1. 2 Algorithms and Programming Languages • Algorithms as written are understandable by humans (natural language) • Natural language is NOT understood by computers (machine language) 0110001001101100001011 Blah 010000001100010011011 Blah 00011000010110100000 Blah 0110001001101100001011 01000 1 -5

1. 2 Algorithms and Programming Languages • Programming language converted to machine language by compiler or interpreter Starting … 0101001101000110000101110010011101000110 100101101110011100100000 out … 0110111010101110100 With … 01110110100101110100000100000 Alice … 0100000101101100011010010110001101100101 1 -6

1. 2 Algorithms and Programming Languages • Operators • + - * / • Perform arithmetic and other functions on data. • Syntax • Set of rules that must be followed. • Similar to the set of rules that are followed when people speak a natural language. • Writing the Program…writing the code • Program consists of keywords, operators, punctuation and more arranged in proper sequence • Save, compile, and voila! An executable program! 1 -7

1. 3 Learning to Program with Alice • Alice uses objects • Tent • Soldier • Princess • Objects perform actions – – Turn Move Fly Wave 1 -8

1. 3 The Alice System 1 -9

1. 3 PLAY 1 -10

1. 3 The Alice Environment World Toolbar View Events Editor Object Tree Details Panel od h t Me itor Ed 1 -11

1. 4 Object Properties Object Selected Change Properties 1 -12

1. 4 Methods • Set of programming statements executed by object. • Methods commonly result in object performing action. My first method 1 -13

1. 4 Methods • Objects made of other objects • Snowman made of: – head • • • top. Hat left. Eye right. Eye carrot. Nose mouth – left. Arm – right. Arm – bottom NOTE: how objects are named! This is called “camel case” 1 -14

1. 4 Methods • Each object can also be manipulated with methods. • Objects and “sub” objects can – Move – Turn – Roll – Say… 1 -15

1. 4 The World is My…object? • Contains all other objects • Also has its own properties – Atmosphere color – Lighting – Fog 1 -16

1. 5 Alice has Class(es)! • Objects are created from classes. • Class set of specifications that describe a particular “type” of object. Each item found in the Gallery is a class. Each time the class is used, it is an instance of that class. Gallery is a collection of different object types (animals, beach, people, etc. ). Two galleries are used: Local gallery (stored on computer) Web gallery (maintained by creators of Alice) 1 -17

1. 5 Blueprint that Describes a House Three instances of the house created from the blueprint (class). 1 -18

1. 5 Class Instance in Alice • Class: Chicken • Instance: – Chicken 1 – Chicken 2 • Each instance has its own properties, methods, functions 1 -19

1. 6 3 D Objects and the Camera • Alice world and objects are threedimensional – Height – Width – Depth } These dimensions are part of 2 D objects 1 -20

1. 6 3 D Movement Forward is perceived as the object getting larger as is it gets closer to us. Motion based on OBJECT’s Backward is perceived the. Coach’s object getting perspective…our left isasthe right smaller as it gets farther away from us. 1 -21

End Of Chapter Programs… • • • Obtain a textbook. Turn to pages 54 -56 Complete 5 of the exercise from 1 -7 and 4 exercises from #8 -#13 to showcase chapter 1 skills in Alice. 1 -22

End Of Chapter Program Enhancement • Using Exercise #1(The snowman and 5 penguins) create the following. • Have the snowman say something(you decide). • Next have the penguins move into a V formation. • The penguin in the front of the V needs to say “Ready, Set, Go”, and the V of penguins needs to run into the snowman. • The snowman should say “Ouch” and then fall apart to the ground. 1 -23
- Slides: 23