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.

Slides:



Advertisements
Similar presentations
Alice Learning to program: Part 1 by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
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.
Class-level Methods and Inheritance Part 1 Alice.
Class-level Methods Chapter 6. Class-level Method Is specific to a class of objects We can give a class new abilities/methods Only involves this one class.
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.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Alice and Media Computation August 2009 Animation Storyboard  Code Steve Cooper Barbara Ericson.
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.
Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
1 Alice: Beyond the Basics Steve Cooper Michelle Venable-Foster Barbara Ericson Aug 2009.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
CS320n –Visual Programming Random Numbers and Random Motion (Slides 6-3) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
Tips & Techniques 6 Random Numbers and Random Motion Alice.
CS320n –Visual Programming Functions Mike Scott (Slides 6-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Classes, Objects, and World-level Methods Alice. Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics.
Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
Alice Learning to program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke.
Methods Tutorial: Part One By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 9, 2008.
METHODS!.  A method is a sequence of instructions or behaviors that will be carried out when requested.  You can use them to create new methods so that.
Functions and Conditionals in Alice 1 Stephen Cooper Wanda Dann Barb Ericson September 2009.
Classes, Objects, and World-level Methods
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.
Using Alice to Introduce Programming Concepts Mr. Craig Ham Technology Coordinator Westminster Schools of Augusta Augusta, GA.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
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.
Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Poses Tutorial Alex Boldt Under the direction of Professor Susan Rodger Duke University July 2015.
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Where are we? Alice is a “toy” language Fundamentals are exactly like “real”
What we will do today Learn about functions in Alice.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
CS320n –Visual Programming Introduction to Recursion (Slides 8-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Programming: Simple Control Structures Part 2 – Repetition Alice.
CS320n – Elements of Visual Programming Lists Mike Scott (Slides 9-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
CS320n – Elements of Visual Programming Sending Parameters to Event Handler Methods (Slides 5-2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
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.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. 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.
Variables and Inheritance Part 1 Alice. Review: Properties A class defines properties for its own kind of object. When an object is created (instantiated),
Beginning Animation. Storyboard An Invitation to Dinner 1.Marlin and Dory (two small fish) are swimming and talking. 2.A shark (Bruce) swims up behind.
1 Quiz Show Programming Terms. 2 Alice - 3D Virtual Programming Vocabulary Quiz Board Chapter 1 Chapter 2a Chapter 2b Chapter 3 Chapter 4 $100 $200 $300.
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
Learn about functions in Alice
Teaching Characters to Walk: Learning Methods, Part 1
Getting started in Alice
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
World-level Methods with Parameters
CS320n –Visual Programming
Alice and Media Computation August 2009
Classes, Objects, and World-level Methods
Class-level Methods Alice.
CS320n –Visual Programming
Classes, Objects, and World-level Methods
Parameters and World-level methods
Classes, Objects, and World-level Methods
Class-level Methods and Inheritance
Class-level Methods and Inheritance Part 2
Presentation transcript:

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 for slides

Visual ProgrammingClass level Methods and Inheritance Part 1 2 Reminders Assignment due tonight by 11 pm

Visual ProgrammingClass level Methods and Inheritance Part 1 3 What We Will Do Today Learn about class level methods and inheritance class work

Visual ProgrammingClass level Methods and Inheritance Part 1 4 Animated Actions Some actions are more naturally associated with a specific class of objects rather than with the overall world. Examples –A person walking –A wheel rolling –A fish swimming If the action involves 2 or more objects in the world it should be a world level method

Visual ProgrammingClass level Methods and Inheritance Part 1 5 Class-level Methods Write a method to add abilities / functions / actions / behaviors to a specific class of objects –class-level method –NOT world-level methods Demo how to build class-level method

Visual ProgrammingClass level Methods and Inheritance Part 1 6 An Example How can we create a skate method for ice skater objects? We need to: (1)create a new method for the ice skater (2)add code to the new method to make it look like the skater “skates”

Visual ProgrammingClass level Methods and Inheritance Part 1 7 Demo: The solution First, to associate the behavior with the ice skater select the iceSkater tile in the Object Tree select the methods tab in the details area click on the "create new method" button

Visual ProgrammingClass level Methods and Inheritance Part 1 8 Storyboard for skate The slide actions –require several motion instructions –… so we’ll break these two actions into smaller pieces –a technique known as stepwise refinement (and abstraction) Skate: Do together move skater forward 2 meters Do in order slide on left leg slide on right leg

Visual ProgrammingClass level Methods and Inheritance Part 1 9 An Aside Shouldn’t the skater already know how to skate? Should people already know how to walk? The objects in Alice are simply 3D models created in other programs –articulating, coloring, setting center point When added to Alice all objects have certain basic behaviors, move, turn, roll, … programmers must write code for more complex behaviors –CLASS-LEVEL METHODS!

Visual ProgrammingClass level Methods and Inheritance Part 1 10 But This Seems So Hard Anecdote 1: Show Kelly Scott anything “cool” the computer does Anecdote 2: Finding Nemo. Making the viewer believe Dory can barely say what she is thinking and how sad she is It is hard. It is complex. Take a look at the penguin method walk

Visual ProgrammingClass level Methods and Inheritance Part 1 11 Penguin Method Walk … and there is more after this. Bottom line. Interesting behaviors are usually complex

Visual ProgrammingClass level Methods and Inheritance Part 1 12 Refined storyboard for skate Refinement of slideLeft Do in order Lift right leg and turn upper body forward Lower right leg and return body upright Skate: Do together 1) move forward 2 meters 2) Do in order slideLeft slideRight Refinement of slideRight Do in order Lift left leg and turn upper body forward Lower left leg and return body upright

Visual ProgrammingClass level Methods and Inheritance Part 1 13 Writing the code The next step is to translate the design into program code. For the slideLeft method, a possible translation is: Design step Instruction Lift the right leg turn the right thigh forward Turn upper body forward turn the upper body forward Lower the right leg turn the right thigh backward Return the body upright turn the upper body backward

Visual ProgrammingClass level Methods and Inheritance Part 1 14 Demo Demonstration of – slideLeft – slideRight – skate Could we parametize slideLeft and slideRight? –should we?

Visual ProgrammingClass level Methods and Inheritance Part 1 15 Correspondence of design to code Skate: Do together move skater forward 2 meters Do in order slide on left leg slide on right leg

Visual ProgrammingClass level Methods and Inheritance Part 1 16 Question Writing the methods to make an ice skater perform a skating motion is an intricate task. Most likely, you would like to reuse these new methods in other worlds. How can you make the skate method available for an ice skater in a different world? –any other ice skaters in this world DO NOT know how to skate

Visual ProgrammingClass level Methods and Inheritance Part 1 17 Answer: Save out as a new class 1) Rename iceSkater as advancedSkater. 2) Save out as a new class. Alice saves the new class as AdcancedSkater.a2c

Visual ProgrammingClass level Methods and Inheritance Part 1 18 Inheritance The AdvancedSkater class – inherits all the properties and methods from the original IceSkater class, and also – has the newly defined methods (skate, slideLeft, slideRight) In other programming languages, the concept of creating a new class based on a previously defined class is called inheritance. –object oriented programming. As opposed to procedural programming or functional programming o or …

Visual ProgrammingClass level Methods and Inheritance Part 1 19 Using CleverSkater An instance of the CleverSkater class can be added to a new world – use File|Import.

Visual ProgrammingClass level Methods and Inheritance Part 1 20 Benefits of Inheritance Inheritance supports – the reuse of program code -- allows the programmer to write code once and use it again later in different programs. – sharing code with others in a team project –The best code in your program is the code you didn’t have to write!