Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exam Wednesday No inclass assignment this week. Friday labs will help with individual homework assignment due Friday midnight Review for exam –Tuesday.

Similar presentations


Presentation on theme: "Exam Wednesday No inclass assignment this week. Friday labs will help with individual homework assignment due Friday midnight Review for exam –Tuesday."— Presentation transcript:

1 Exam Wednesday No inclass assignment this week. Friday labs will help with individual homework assignment due Friday midnight Review for exam –Tuesday 1:30-3 in Main 416 –Tuesday 7-8, in SER 005 –Posted Study Guide No make-ups given without prior approval 2-1

2 Review of chapter 9 Center of an object is not computed – it depends on what is most useful for the object. When you move an object to the world (0,0,0) - it will often be half beneath the ground Where should the “center” of the following be: –bat –person –fish –ball The answers depend on what the object designer thought you would want to do with it. 2-2

3 Starting Out with Alice: A Visual Introduction to Programming First Edition by Tony Gaddis Chapter 10: Programming in Alice

4 3D text – can be created like any object 2-4

5 You can also add a jpg, gif, or tif file… Go to file> Make Billboard Then select the file you want to include RightClick>Copy is invaluable! Be sure to use undo! That can save lots of frustration 2-5

6 2-6 Chapter 10 Objectives To understand: –method naming conventions –what dot notation is –what a primitive method is and which objects have them –what is meant by “calling” –what an argument is in a program. –differences in naming conventions –the steps of the program development cycle –what a logical error is –the need for commenting

7 Tips You will learn Alice best by exploring – like you would with a new cell phone. You take it out of the box – poke and prod. You have a general idea of what you would like to do.This directs your exploration (how can I make creation of similar instructions easier?) As you discover interesting things, them to me and I’ll post them! ALICE is the vehicle to explore algorithms, programming concepts, and logical thinking. Proficiency in ALICE is NOT THE GOAL. 2-7

8 2-8 Writing Methods What is a method? –set of instructions that execute –create methods by dragging tiles into the Method Editor –these tiles are the instructions my first method

9 2-9 Naming Conventions dot notation –world.my first method dot (period) separates pieces of information –left side: object that the method belongs to in this case…the method belongs to the WORLD object –right side: name of the method in this case… “my first method” –later on we’ll have coach.yell or frog.jump dot notation “qualifies” the command – who yells the period is called a “dot” 2.1

10 Method names should be meaningful 2-10 Rightclick to rename

11 2-11 world.my first method Events Editor identifies which method plays or is acted upon when the “Play” button is hit 2.1

12 2-12 world.my first method Methods play the instructions (tiles) that are dragged into the Method Editor This method of creating instructions is a bit tedious, but is done to reduce errors 2.1

13 2-13 Primitive Methods – ALL objects can do All objects have a common set of built-in method for performing actions. All objects can move, turn, change size, and more. Example: Hare has primitive methods to move, turn, roll, resize, say dot notation: hare.move 2.1

14 2-14 Terminology Calling the method. hare.move (like subject/verb) –executing or performing the instructions of a method Argument: –piece of information that a method needs in order for it to execute –hare.move…which direction? the direction…up, down, left, right…is the argument Passing the Argument: –the method is called and the arguments are presented object method argument 2.1

15 2-15 Editing Tag Holds possible additional arguments What appears depends on the method called –duration specifies amount of time for action to take place default (1 second) 2.1

16 2-16 Deleting – be sure to click on instruction itself not the object Right-click the instruction and select delete OR drag the instruction tile to the trash can 2.1

17 2-17 Copying Right-click the instruction and select copy Drag the instruction tile to the clipboard –when the clipboard turns green, drop the tile –Later, click on the clipboard and drag it back to the Method Editor –The clipboard only contains one thing at a time. You can request multiple clipboards. (Edit>Preferences>SeldomUsed) 2.1

18 2-18 Custom Methods In addition to primitive methods (the things that ALL objects can do)…some objects have custom methods When objects is selected from gallery, a listing of custom methods appears Names of the custom methods give clues as to what the method does What do you think the foottap custom method does? 2.1

19 2-19 namingConventions Names are known as identifiers…because they identify items in a program Use a name that provides meaning –Name of method should indicate the method’s purpose 2.2 Which one coaches the Knights and which one coaches the Cougars?

20 2-20 namingConventions Most programming languages do NOT recognize spaces –Alice allows spaces method.my first method When spaces are not allowed, how do you combine more than one word in naming? –Capitalize subsequent words –Called camelCase 2.2 Note the space Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Which is easier to read? onehumpcamel or oneHumpCamel

21 2-21 Class Names method names begin with a lower case letter Class names are capitalized This simple capitalization rule is very helpful. No spaces, so each word is capitalized –This convention is called PascalCase 2.2

22 2-22 Renaming Objects –Right-click object’s tile in the object tree and select rename. Methods –Select the world object –Select the method’s tab from the Details Panel –Right-click the “my first method tile” and select rename. 2.2

23 Let’s try the following Playing ball Two players kick ball back and forth What happens together? What if we want to add a frog on top of the ball? What if we want the ball to spin? What if we want the ball to bounce? 2-23

24 Orientation If you want two objects to move together, there are two choices: –they can have the same orientation (same coordinate system orientation) – orient to –one can be a vehicle for the other. (Under properties for “riding” object) 2-24

25 As seen by You know each object has it’s own sense of direction, but suppose we want the ball (which may be twisted) to bounce upwards with respect to the ground. Select “move up” but use “more” to request “asSeenBy = ground” 2-25

26 Move to Alice can move objects to a particular location, but it is more likely it moves to another location in the scene. Try using moveTo to go to the camera MoveToward allows you to move in the direction of an object without aligning center points. 2-26

27 2-27 Designing a Program Design requires planning…that follows the above steps Called program development cycle Cycle is repeated until there NO errors appear in the program. 2.3 Design the programWrite the methodsTest the methodsDebug the methods

28 Why design? It is common for students just to start! Why should they take the time to jot down a plan? –Solve the right problem –Allow for reuse – plan to use the same code. On magnets, for example, - do all the objects get to the magnet the same way? Will the instructions work from any location? Which is better for reuse? 2-28

29 Decomposition The machine only understands about 100 operations. What makes it difficult if the ways they are put together. Chess – only six types of chess pieces which move in simple patterns. The complexity comes with the combinations In programming we need a way of managing the pieces. used interchangeably: decomposition, stepwise refinement, top-down design 2-29

30 2-30 Comments A comment is a note explaining the code Crucial part of the code Makes the code understandable Alice ignores comments when it runs your program 2.4 // comment tile

31 2-31 Tips for Setting Up the Initial Scene Methods can also be called to help in initial positioning Use the primitive methods to setup the scene –Select the object in the Object Tree, then select a method Use the primitive methods to position the objects –Doing so from the Object Tree positions the objects outside of the program 2.5

32 10-32 Tips for Setting Up the Initial Scene Moving an object to the center of the world –Use the move to method and choose the entire world as the method’s argument –Places the object’s center point at the world’s center point of (0, 0, 0) 2.5

33 2-33 Tips for Setting Up the Initial Scene Positioning objects a specified distance apart –Use the move to method and choose asSeenBy the other object for the method’s argument –Places the object’s center point at the world’s center point of (0, 0, 0) 2.5

34 2-34 Tips for Setting Up the Initial Scene Moving the camera to an object –Right-click the object and choose Camera get a good look at this –Camera moves to a position so the object is in plain view 2.5

35 2-35 Executing Instructions Simultaneously By default, instructions are executed one after the other…in the order they appear in the Methods Editor For simultaneous actions, drag Do together into the Methods Editor Other instructions can be place within the Do together tile Make sure the duration for all items in a Do together are the same 2.6

36 2-36 The Do in order Structure By default, all instructions are performed in order they appear in the Methods Editor Do in order structure used when more than one set of actions must occur simultaneously…but has steps that must be done in order 2.6


Download ppt "Exam Wednesday No inclass assignment this week. Friday labs will help with individual homework assignment due Friday midnight Review for exam –Tuesday."

Similar presentations


Ads by Google