Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Chapter 1:

Similar presentations


Presentation on theme: "Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Chapter 1:"— Presentation transcript:

1 Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Chapter 1: Introduction to Alice and Objects

2 1-2 Lessons in this chapter 1.What is a Computer Program? 2.Algorithms and Programming Languages 3.Learning to Program with Alice 4.Objects 5.Classes and the Alice Galleries 6.3D Objects and the Camera

3 1-3 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.1

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

5 1-5 Algorithms and Programming Languages Algorithm –Set of well-defined logical steps –Must be performed in order to perform a task 1.2

6 1-6 http://www.youtube.com/watch?v=7pRXGywEsdo

7 1-7 Algorithms and Programming Languages Example … Making a Peanut Butter and Jelly Sandwich. 1.2

8 1-8 Algorithms and Programming Languages Example … Making a Peanut Butter and Jelly Sandwich. If we had a robot that could follow our commands, what would we tell it to do? Think of some verbs that we will use to command our robot what to do. 1.2

9 1-9 Algorithms and Programming Languages Example … Making a Peanut Butter and Jelly Sandwich. If we had a robot that could follow our commands, what would we tell it to do? Think of some verbs that we will use to command our robot what to do. Let’s use those commands and write an algorithm for our robot. 1.2

10 PB&J? Yum! The average American child eats 1,500 peanut butter sandwiches by the time he graduates from high school. 1-10

11 Fun Facts About Peanut Butter Peanut butter is the leading use of peanuts in the USA. Peanut butter was the secret behind "Mr. Ed," TV's talking horse. It takes about 540 peanuts to make a 12-ounce jar of peanut butter. There are enough peanuts in one acre to make 30,000 peanut butter sandwiches. Peanut butter was first introduced to the USA in 1904 at the Universal Exposition in St. Louis by C.H. Sumner, who sold $705.11 of the "new treat" at his concession stand. Peanut butter is consumed in 89 percent of USA households. Women and children prefer creamy, while most men opt for chunky. People living on the East Coast prefer creamy peanut butter, while those on the West Coast prefer the crunchy style. November is Peanut Butter Lovers Month. Arachibutyrophobia is the fear of getting peanut butter stuck to the roof of your mouth. The world's largest peanut butter and jelly sandwich was created in Oklahoma City, OK, on September 7, 2002 by the Oklahoma Peanut Commission and the Oklahoma Wheat Commission. The PB & J sandwich weighed in at nearly 900 pounds, and contained 350 pounds of peanut butter and 144 pounds of jelly. The amount of bread used to create the sandwich was equivalent to more than 400-one pound loaves of bread. Sixty percent of consumers prefer creamy peanut butter over crunchy. The patent for peanut butter was awarded to Dr. John Harvey Kellogg in 1895. Americans spend almost $800 million a year on peanut butter. Americans eat enough peanut butter in a year to make more than 10 billion peanut butter and jelly sandwiches. 1-11

12 Fun facts about jelly Jelly is made from fruit juice. Jelly is clear and firm enough to hold its shape when turned out of its container. Jam is made from a blend of crushed pieces of fruit and fruit puree. Preserves contain whole or large pieces of fruit, making them thicker and more fruit- filled than jams or jellies. Marmalade is jelly with shreds of citrus fruit peel. Conserves are jams made from a mixture of citrus fruits and can also include nuts. Fruit butters are made from fruit pulp and sugar cooked together. There is no butter in fruit butter. The term may have developed to describe the appearance of the product or because it is a spread. Chutney and relish are flavorful, seasoned condiments with a consistency similar to jam. Chutney is typically made with fruits and relish is typically made with vegetables. 1-12

13 1-13 Algorithms and Programming Languages Algorithms as written are understandable by humans (natural language) Blah 0110001001101100011000010110 1000001000000110001001101100 011000010110100000100000 0110001001101100011000010110 1000 Natural language is NOT understood by computers (machine language) 1.2

14 1-14 Algorithms and Programming Languages Programming language converted to machine language by compiler or interpreter Common programming languages are Java, C++, Visual Basic, Pascal. Starting …01010011011101000110000101110010011101000110 1001011011100110011100100000 out …011011110111010101110100 With …0111011101101001011101000110100000100000 Alice …0100000101101100011010010110001101100101 1.2

15 1-15 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.2

16 Checkpoint p. 5 1. What is a computer? 2. What is a program? 3. What is an algorithm? 4. What is the only language that computers understand? 5. Why were programming languages invented?

17 1-17 Learning to Program with Alice In this course we will learn to program by using a software system named Alice. –Developed by Carnegie Mellon University as a teaching tool to make programming easy to learn. –No typing (therefore no syntax errors) –Uses tiles that you drag and drop to create your program. Alice makes programming fun and exciting because it allows you to create 3D animations and computer games while learning programming concepts. In Alice you will create 3D virtual worlds populated by people, animals, fantasy creatures, vehicles, and a variety of other objects. 1.3

18 1-18 Learning to Program with Alice Alice uses objects –Tent –Soldier –Princess Objects perform actions –Turn –Move –Fly –Wave We can use Alice to create worlds that tell a story. 1.3

19 Why is it called “Alice”? Alice pays homage to Lewis Carroll, author of Alice's Adventures in Wonderland and Through the Looking Glass. Carroll was a mathematician, novelist, and photographer. Most important, he could do intellectually difficult things but also realized the most powerful thing was to be able to communicate clearly and in an entertaining way. This inspires our efforts to make something as complex as computer programming easy and fun. The name is also a very practical choice. The artwork associated with the Alice books is now in the public domain, its copyright having lapsed. Also, the name "Alice" has several other advantages: –It's easy to spell. –It's easy to pronounce. –It shows up near the top of alphabetical lists. 1.3

20 1-20 The Alice System 1.3

21 1-21 The Alice Environment Toolbar World View Events Editor Object Tree Details Panel Method Editor 1.3

22 Tutorial 1-1 Open and Play an Alice World –snowLove 1.3

23 Checkpoint p. 12 6. How do you control the speed at which a world is played? 7. What part of the Alice environment displays a view of the world, as seen through the camera? 8. What part of the Alice environment displays a list of the objects in the world? 9. What is a tile? What purpose of tiles was discussed in this section? 1.3

24 1-24 Objects Alice worlds are made of objects –snowman, snowwoman, island Alice provides galleries of many different types of objects 1.4

25 1-25 Object Properties Properties are values that specify the object’s characteristics. Once you place an object in the world, you adjust its properties until it has the properties you want. Object Selected Change Properties 1.4

26 Methods Set of programming statements executed by object. Methods commonly result in object performing action. 1-26 My first method 1.4

27 1-27 Methods Objects made of other objects Snowman made of: –head topHat leftEye rightEye carrotNose mouth –leftArm –rightArm –bottom NOTE: how objects are named! This is called “camel case” 1.4

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

29 Checkpoint p. 16 10. What are properties? 11. What is the name of the property that determines an object’s color? What is the name of the property that determines whether you can see through an object? 12. What is a method? 13. Give an example of how an object can be made of other objects. 1-29 1.4

30 Alice has Class(es)! Objects are created from classes. A class is a set of specifications that describe a particular “type” of object. Alice provides galleries with collections of classes that can be used to create objects. 1-30 1.5 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)

31 Blueprint that Describes a House 1-31 The blueprint is not a house, but a detailed description of a house. When we use the blueprint to build an actual house, we say we are building an instance of the house that is described by the blueprint. We can build several identical houses from the same blueprint, but each house is a unique instance of the house. 1.5

32 Class Instance in Alice Local Gallery: Animal Class: Chicken Instance: –Chicken1 –Chicken2 Each instance has its own properties, methods, functions 1-32 1.5

33 Our First Program Hello World! Story: An astronaut has landed on the moon. He looks into the sky and sees the earth. He says, “Hello World”. Refer to Tutorial 1-2 for creating and adding objects. 1.5

34 Main program 1.5

35 3D Objects and the Camera Alice world and objects are three- dimensional –Height –Width 1-35 1.6 –Depth } These dimensions are part of 2D objects

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

37 The Camera 1-37 This control moves the camera up, down, left, and right This control moves the camera forward and backward, and rotates it left and right. This control tilts the camera up and down. The camera’s purpose is to display an image of the world in the World View window. The image that is displayed in the World View window is the view of the world seen through the camera’s viewfinder. The camera’s position, including the direction it is pointed in, is called the camera’s viewpoint. 1.6

38 Modifying Objects in 3D Mouse mode buttons are used to –Move objects freely –Move up/down –Move left/right, –Forward/backward –Tumble –Resize –Copy. 1-38 1.6

39 Single View and Quad View Modes Single view – one view of the world. –The World View window Quad view – four views of the world. –The World View window –A view from the top –A view from the right –A view from the front 1-39 1.6

40 Buttons Move objects Freely Scroll view Zoom 1-40 1.6

41 Checkpoint p. 31 14. What is a class? 15. How are a class and instances of the class similar to a blueprint and houses built from the blueprint? 16. What is stored in the Alice galleries: classes or objects? 17. When you click the Add Objects button, what mode does Alice go into? 1-41

42 Checkpoint continued 18. After finding the class you want in one of the Alice galleries, describe two ways to add an instance of the class to the world. 19. What are the two ways to select an object in the Alice environment? 20. What appears around an object in the World View window when you select the object? 21. Would the word dog be the name of a class, or the name of an object? How can you tell? 22. In what area of the Alice environment do you select an object’s properties? 1-42

43 Tutorial 1-3 Moving the camera in 3D space 1-43

44 Tutorial 1-4 Manipulating objects in 3D space 1-44

45 Tutorial 1-5 Manipulating subpart objects 1-45

46 Checkpoint p. 50 23. What dimensions do two-dimensional objects have? Three-dimensional objects? 24. In what directions may an object in a two- dimensional world move? Three-dimensional objects? 25. What are the seven mouse mode buttons? 26. Why would you want to know where an object’s center point is before you rotate the object? 1-46

47 Checkpoint continued 27. When you select an object you see three axes displayed in the vicinity of the object. These axes indicate the object’s orientation. In what direction does each of the axes point? 28. What four views do you see when in quad view mode? 29. Which mouse mode button is not displayed when in quad view mode? Why is the button not displayed? 30. In a 3D system, what do the numbers in a coordinate such as (5,0,1) indicate? 1-47

48 Review Questions p. 51 1-48

49 Short Answer p. 53 1-49

50 Exercises p. 54 Choose 3 1.Snowy World 2.Table Set for Four * required 3.Moon World 4.Talking Coaches 5.City Street 6.Medieval Scene 7.Farm Scene 8.Birthday Party 1-50


Download ppt "Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Chapter 1:"

Similar presentations


Ads by Google