Methods (part 1) Alice In Action, Ch 2 Slides Credit: Joel Adams, Alice in Action CS120 Lecture 02 31 August 2012.

Slides:



Advertisements
Similar presentations
Chapter 3: Modules, Hierarchy Charts, and Documentation
Advertisements

Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Alice in Action with Java Chapter 7 From Alice to Java.
Alice in Action with Java
Alice in Action with Java
CS350/550 Software Engineering Lecture 1. Class Work The main part of the class is a practical software engineering project, in teams of 3-5 people There.
Creating an Animation Program Alice. Step 1: Design Decide on the problem to be solved Design a solution We will use a storyboard design technique, commonly.
Alice in Action with Java
Classes, Objects, and World-level Methods Alice. Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Methods Tutorial: Part One By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 9, 2008.
Introduction to Alice Alice is named in honor of Lewis Carroll’s Alice in Wonderland.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Programming Logic Program Design. Objectives Steps in program development Algorithms and Pseudocode Data Activity: Alice program.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Alice Learning to program: Part Three Camera Control, Invisibility, and 3-D Text By Ruthie Tucker and Jenna Hayes, Under the direction of Professor Rodger.
Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Events (2) (Alice In Action, Ch 6) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
The Very Basics of Alice: A Simple Overview 6 th & 7 th Grade Tech Apps.
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 2Advanced Reports, Access Tools, and Customizing Access Chapter 6Using Access Tools and Managing.
Scene changes By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June
UHD::3320::CH121 DESIGN PHASE Chapter 12. UHD::3320::CH122 Design Phase Two Aspects –Actions which operate on data –Data on which actions operate Two.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Introduction to Alice Alice is named in honor of Lewis Carroll’s Alice in Wonderland Slides Credit: Joel Adams, Alice in Action CS120 Lecture August,
Flow Control: Repetition with For Loops (Alice In Action, Ch 4) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
Creating An Animation Program Alice. Step 1: Design Decide on the problem to be solved Design a solution We will use a storyboard design technique, commonly.
Storyboarding1 Steve Cooper Barb Ericson August 2009 Storyboarding.
Animation Programs: Scenarios and Storyboards
Flow Control: boolean expressions, “if” selection statements (Alice In Action, Ch 4) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September.
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
Events (Alice In Action, Ch 6) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
3D Animation Concepts CS0007 George Novacky. Overview Creating a new world (slides 5 – 13) Remembering camera position (slides )
Creating an Animation Program
Making Billboards By Deborah Nelson Duke University, Under the direction of Professor Susan Rodger, July 14, 2008.
Microsoft Outlook 2010 Instructor: Julie Thorngren
Alice in Action with Java Chapter 5 Lists and Arrays.
Review: the Dummy Marker Typically used for: Positioning large and small objects in a scene Remembering camera positions for multiple scenes Remembering.
Lesson 4.  After a table has been created, you may need to modify it. You can make many changes to a table—or other database object—using its property.
Variables (Alice In Action, Ch 3) Slides Credit: Joel Adams, Alice in Action CS120 Lecture 04 7 September 2012.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Methods (part 2) Alice In Action, Ch 2 Slides Credit: Joel Adams, Alice in Action CS 120 Lecture 03 4 September 2012.
Skater World: Part Three By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009.
1 Data Structures CSCI 132, Spring 2014 Lecture 1 Big Ideas in Data Structures Course website:
Flow Control: Repetition with While Loops (Alice In Action, Ch 4) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
Alice in Action with Java Chapter 4 Flow Control.
Creating an Animation Program Alice. The programming steps.
1 Using Rational Rose ® to construct UML diagrams.
Alice in Action with Java Chapter 4 Flow Control.
Presenter: Carol Liss Timberlane Regional Middle School 6 th and 7 th grade Tech. Educator Co presenters:
Alice in Action with Java Chapter 1 Getting Started with Alice.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Creating an Animation Program Alice. Step 1: Design Decide on the problem to be solved Design a solution We will use a storyboard design technique, commonly.
Functions (Alice In Action, Ch 3) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
Alice in Action with Java Chapter 2 Methods. Alice in Action with Java2 Objectives Build world-level methods to help organize a story into scenes and.
Alice Learning to program: Part Three Camera Control, Invisibility, and 3-D Text By Ruthie Tucker and Jenna Hayes, Under the direction of Professor Rodger.
Programming Logic Alice.
Alice in Action with Java
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Classes, Objects, and World-level Methods
Class-level Methods Alice.
Alice in Action with Java
Creating an Animation Program
Alice in Action with Java
Introduction to Object-Oriented Programming in Alice
Learning to Program: Part 3 Camera Control, Invisibility and 3-D Text
Presentation transcript:

Methods (part 1) Alice In Action, Ch 2 Slides Credit: Joel Adams, Alice in Action CS120 Lecture August 2012

Objectives Build world-level methods to help organize a story into scenes and shots Use dummies to reposition the camera for different points of views within a scene Understand how an object’s position, orientation, and point of view are described, changed and determined Documenting your code with comments. Understand Flow of Control with methods. 2

Methods – behavior-producing messages (from the sender’s view) – behaviors/actions in response to requests, messages (from the recipient’s view) – E.g. in world.my_first_method: whiteRabbit.pointat(camera) Convention for naming methods – Name should be a verb or verb phrase – Name should describe what the method does A method is a way to name a block of code. 3

Methods Objects have predefined methods for common tasks Methods may also be created by Alice developers – Two main reasons for building your own methods To provide an object with additional behaviors (Next week) To organize your story and program into more manageable pieces (Today) Divide and conquer methodology – Break a big problem into smaller problems – Solve each of the smaller problems – Combine the solutions of smaller problems into a solution for the original, big problem Hiding complex details with abstraction. Alice in Action with Java4

World Methods for Scenes and Shots User stories can be divided into scenes and shots – Scene: segment of a story, usually set in one location – Shot: part of a scene, normally from one fixed camera view Use multiple scenes and shots to create a program that reflects the user story and has a modular design 5 Two shots of one scene

Methods for Scenes Example: develop a user story with three scenes Creating the first new method – Select the world object – Click the create new method in the details area – Enter playScene1 in the New Method dialog box Check new method by sending say() to ground – First test fails because my_first_method() is empty 6

Alice in Action with Java7 Methods for Scenes (continued)

Alice in Action with Java8 Methods for Scenes (continued)

How to fix the first bug – Click on the tab for my_first_method – Drag a doInOrder control to the top of the pane – Click on world in the object tree – Drag playScene1() into the doInOrder statement Extend technique used to build playScene1() – Add two methods: playScene2(), playScene3() – New method sends a say() message to the ground – New Methods are called in my_first_method() Alice in Action with Java9

10 Methods for Scenes (continued)

11 Methods for Scenes (continued)

Methods for Shots Example of a scheme using scenes and shots – Level 1: my_first_method() – Level 2: three methods for three scenes – Level 3: four methods for four shots in Scene 2 12

Methods for Shots (continued) Implementing the scheme – Test each shot in Scene 2 using a say() method – Call the four shot methods from playScene2() – Call three scene methods from my_first_method() Structure diagram reflects organization of user story Scene and shot messages are stored in the world Alice in Action with Java13

Alice in Action with Java14 Methods for Shots (continued)

World and Object Methods World method: affects behavior of all objects in a world Object method: defines behavior for a single object (that may have multiple parts) – examples : flapWings() for dragon, hop() for a rabbit… Alice in Action with Java15

Program Documentation Standalone readme, manual… Comments: explanatory remark ignored by Alice – an integral part of code – Used to describe what code does at various levels the overall program, individual methods, blocks of statements…. – Useful for collaborators and developers themselves – Important part of programming Also a component evaluated for your program grades Alice in Action with Java16

Alice Tip: Using Dummies Review – Scenes comprise shots – Shots are filmed with the camera in a given position – Alice places a camera object in every world Two techniques for shifting position of camera – Use set of motion-related messages, such as move() – Use an invisible marker called a dummy 17

Dummies Dummy: invisible marker with a point of view Dummies are used to change a camera’s position Description of a scene that will use dummies – Wizard intervenes to prevent trolls from taking a castle – Camera changes position for each of three shots – Story conforms to structure in Figure 2-11 (less Shot 4) Setting up the first shot of Scene 2 – Add castle, wizard, and trolls to build the scene – Click more controls button and then drop a dummy – Go to object tree and rename dummy scene2Shot1 18

19 Dummies (continued)

20 Dummies (continued)

Setting up the second shot of Scene 2 – Using camera controls, zoom in on the wizard – Press the drop dummy at camera button – Rename the second dummy, scene2Shot2 Setting up the third shot of Scene 3 – First dummy will be reused for this shot After dummies are inserted they will be programmed 21

Alice in Action with Java22 Dummies (continued)

Using setPointOfView() to Control the Camera obj.setPointOfView(obj2) – Changes the position of obj to obj2 – Example: camera.setPointOfView(aDummy) Adding code to the first shot of Scene 2 – Drag a doInOrder statement to the editing area – Click on camera object in the object tree – Drag setPointOfView() to the editing area Select scene2Shot1 dummy as target and 0 duration – Add say() statements for each of the trolls – Add a comment to explain the purpose of the method Alice in Action with Java23

Alice in Action with Java24 Using setPointOfView() to Control the Camera (continued)

Alice in Action with Java25 Using setPointOfView() to Control the Camera (continued)

Adding code to the second shot of Scene 2 – Set the opacity of the wizard to 0 in properties pane – Drag wizard ’s opacity property to editing area Set the opacity to 1 in the set() method – Set the camera ’s point of view to scene2Shot2 – Add a say() statement for the wizard Adding code to the third shot of Scene 2 – Reset camera’s point of view to scene2Shot1 – Point the three trolls at the wizard Set message’s onlyAffectYaw attribute to true 26

27 Using setPointOfView() to Control the Camera (continued)

28 Using setPointOfView() to Control the Camera (continued)

Summary Divide and conquer approach: decomposing a user story into scenes and shots Define methods to support modular design and provide advanced operations World methods: messages sent to the world Comments: remarks that explain program statements Flow of Control: How methods modify sequential execution. Dummy: invisible marker with position and orientation (a point of view) 29

Student To-Do No lab on Monday (Holiday) Hopefully we’ll do a lab on Tuesday First homework will go out on Tuesday. – For now, practice on your own with Alice Readings: – Ch 1, Ch 2 Alice in Action with Java30