Classes, Objects, and World-level Methods Alice. Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics.

Slides:



Advertisements
Similar presentations
Visual Lists By Chris Brown under Prof. Susan Rodger Duke University July 2012.
Advertisements

CS320n –Visual Programming Class-level Methods and Inheritance – Part 1 Mike Scott (Slides 4-3-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger.
Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Class-level Methods and Inheritance Part 1 Alice.
Review of Chapter 4 Sections 1 and 2 World-level methods involve two or more objects break a large problem into smaller, logical units follow a design.
CSC1401 Animation Creating methods/instructions (class-level)
World-level Methods with Parameters Alice. Larger Programs As you become more skilled in writing programs, you will find that your programs quickly begin.
Lights Camera Action! Part 3: BDE Events By Deborah Nelson under the direction of Professor Susan Rodger Duke University July 2008.
Alice: A Visual Introduction to Programming Chapter 1 Part 2.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Implementation Algorithm  Code World.my first method Control blocks Statements (methods,
Animation Programs Alice. Overview 4-step process for creating animations Step 1: Understand Problem Step 2: Design Step 3: Implementation Step 4: Test.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Classes, Objects, and World-level Methods
Programming Logic Program Design. Objectives Steps in program development Algorithms and Pseudocode Data Activity: Alice program.
Today’s Agenda 1.Collect Pre-Lab 4 2.Alice Programming Assignment Storyboards 3.Classes 4.Objects 5.Methods 6.Assign pair programming teams and meet upstairs.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Classes, Objects, and World-level Methods Section 47 Web Design.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
CS320n –Visual Programming Introduction to Alice Mike Scott (Slides 2)
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June
Class-level Methods Chapter 6 part 1. Classes and Objects Classes o In Alice, classes are predefined as 3D models Objects o An object is an instance of.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Creating An Animation Program Part 2 Alice. Method A segment of program code (instructions) that defines how to perform a specific task.
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
Animation Programs: Scenarios and Storyboards Alice.
Alice: A Visual Introduction to Programming Chapter 1 Part 2.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Animation Programs Alice.
Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
CompSci 4 Chap 4 Sec 1 Sept 15, 2005 Prof. Susan Rodger.
CS320n –Visual Programming Classes, Objects, and World- Level Methods Mike Scott (Slides 4-1)
Classes, Objects, and World-level Methods MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
The Essentials of Alice Mrs. Jayne Slease SBMS CTE Computer Science and Animation Credit to Duke Students under the direction of Professor Susan Rodger.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Changing Camera Views! Part 1: Set Point of View to By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July 2013 Updates.
World-level Classes Chapter 6 Part 2. Programs Grow Program code grows larger over time This makes it more difficult to read and process the code in our.
Creating An Animation Program Alice. Recall from last lecture We began the animation creation process We introduced the concept of storyboard We will.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Creating an Animation Program Alice. The programming steps.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Animation Programs: Scenarios and Storyboards Alice.
Programming in Alice IT-IDT-9 Design, develop, test and implement programs using visual programming. 9.1 Utilize drag and drop software to develop programs.
Using Placeholders to Simplify your Methods: Learning Methods, Part 2 By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
The Essentials of Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University May 2009.
Alice in Action with Java Chapter 1 Getting Started with Alice.
An Introduction to Programming Using Alice 2.2, Second Edition Chapter 7 Recursive Algorithms.
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.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
Programming Logic Alice.
World-level Methods with Parameters
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
Classes, Objects, and World-level Methods
Chapter 2: Programming in Alice
Classes, Objects, and World-level Methods
Creating An Animation Program
Class-level Methods and Inheritance
Presentation transcript:

Classes, Objects, and World-level Methods Alice

Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics (properties, methods, and functions) of an object of a specific type Object An instance of a class; each object of one class has identical characteristics, but property details may vary

Programming in Alice© 2006 Dr. Tim Margush3 Method / Function Method A programming unit that can be executed on demand by using its name; corresponds to a sequence of actions Function A programming unit that can be executed on demand by using its name; represents a value

Classes, Objects, & Methods Object-oriented programming uses classes, objects, and methods as basic programming components. These components help you to design programs think about an intricate program test programs find and remove errors (bugs)

In your programs, you have been using… Classes In Alice, classes are predefined as 3D models Objects An object is an instance of a class.

Capitalization is a matter of Style Classes Classes: Penguin (Uppercase name) Objects Objects: penguin, penguin1, penguin2, opus (lowercase names)

In your programs, you have also used… built-in (predefined) methods Examples: move, turn to face, say World.my first method Example: In the snowpeople world (Chapter 2), we wrote program code where the snowman tried to get the attention of a snowwoman. As a reminder, see next slide…

Elements of Visual Programming Animation Programs8 Adding Instructions to world.my first method The method should be open in the method editor window of Alice. (bottom right) if not select the world from the object tree, the method tab, and click the edit button next to my first method

Elements of Visual Programming Animation Programs9 Method Editor Window

Elements of Visual Programming Animation Programs10 Step 1 – Snowman turns Select the object you want to perform the object Select the method / action you want the object to perform could use turn or turn to face often many ways to accomplish the same task Click and drag it to the method editor window

Elements of Visual Programming Animation Programs11 Snowman Turns Can adjust aspects of how the snowman turns to face the snowwoman click the more option right now duration and style are the only things you should alter

Elements of Visual Programming Animation Programs12 Step 2 – Combined Action We want the snowman to say “ahem” and blink at the same time actions are normally sequential to do actions together, at the same time, use a “Do together” block Click and drag “Do together” block into the method

Elements of Visual Programming Animation Programs13 Affecting subparts The snowman does not have “blink eyes” method Can accomplish a blink by affecting subparts Select snowman object from object tree and expand subparts expand the head now we can give commands to individual parts, in this case the eyes have eyes move up and down specify direction and distance of move

Elements of Visual Programming Animation Programs14 Step 2 – First Attempt world.my first method looks like this TEST the method play the movie. Does it do what we want?

Elements of Visual Programming Animation Programs15 Logic Error The program works, but does not do what we intended. This is an example of a logic error very easy in Alice to see logic errors the movie does not do what we wanted What’s the problem?

Elements of Visual Programming Animation Programs16 Do together and Do in order All commands in the Do together block are executed simultaneously So what is the result if you move an eye up.1 meters and down.1 meters at the same time? Apparently nothing So while we want the eyes to move together and to say “ahem” we want the eyes to first move up and then down Use a Do in order block inside the Do together block

Elements of Visual Programming Animation Programs17 Corrected Do Together

Larger Programs As you become more skilled in writing programs, you will find that your programs quickly begin to increase to many, many lines of code. Games and other "real world" software applications can have thousands, even millions of lines of code. In this session, we begin to look at organizing large programs into small manageable pieces.

Goals of OOP Organize a large program into small pieces Design and think about an intricate program Reusable code allows for well written piece of code to work in more than one program Test find and remove errors (bugs)

Modifying the program To make the snowpeople animation more realistic, we might want the snowman to be a little less shy. In our original program, the snowman tries to catch the snowwoman's attention only once. Perhaps he could try to get her attention more than once. To make this modification, additional lines would be added to the code. This would make the program code longer and more difficult to read and think about.

A Solution A solution to the problem is to define our own method name the new method catchAttention Then, we can drag-and-drop the catchAttention method into the edit box just like the built-in methods

Demo: The solution First, to associate the new method with the World select the World tile in the Object Tree select the methods tab in the details area click on the "create new method" button

Demo A demonstration of writing the catchAttention method

World-level method catchAttention is a world-level method because it is defined as a method for World has instructions that involve more than one object (snowman, snowwoman, camera)

Using the catchAttention method The catchAttention method is executed by calling (invoking) the method from my first method

Why? Why do we want to write our own methods? saves time -- we can call the method again and again without reconstructing code reduces code size – we call the method rather than writing the instructions again and again allows us to "think at a higher level" can think “catchAttention" instead of “turn head to face the camera, then say ‘Ahem’ while moving eyes up and down" the technical term for "think at a higher level" is "abstraction"

Assignment Read Tutorial04 World-level Methods How to create them How to call them When it is appropriate to use them Lab04