Creating a Fancier Chicken to use in several worlds - Inheritance Susan Rodger Duke University June 2009.

Slides:



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

Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Alice Learning to program: Part Four Creating Sounds, Making Billboards, Fun with 3-D Text, New Events, and Rotating Objects by Ruthie Tucker and Jenna.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Vehicle Property and Inheritance By Ruthie Tucker, under the direction of Professor Susan Rodger, Duke University, 2008.
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Scene changes By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2008.
Lights Camera Action! Part 3: BDE Events By Deborah Nelson under the direction of Professor Susan Rodger Duke University July 2008.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University Feb. 24, 2007.
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.
Shorter of two objects and changing color Functions, events and setting the color Susan Rodger, Duke University June 2008.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Lights Camera Action! Part 2: Controlling Light in Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June 2009.
Checking for Collisions Ellen Yuan Under the direction of Professor Susan Rodger at Duke University June 2014.
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
3–D Helium Molecule Tutorial Alice Project Duke University Professor Susan H. Rodger Gaetjens Lezin June 2008.
Checking for Collisions: Alternative Method Erin Taylor Under the Direction of Susan Rodger July 2015 Duke University.
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.
Methods Tutorial: Part Two By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
Now that the kangaroo and the turtle have raced, let's make a method for the kangaroo to hop back to the turtle and challenge him to a race again. Click.
Tutorial on Kangaroo visiting his animal friends - parameters, events.
By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Scene changes By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
Lists Tutorial By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
A Simple Quiz: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
The Essentials of Alice (Bunny) By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Illuminating Computer Science CCIT 4-6Sep
Creating a Historical Tour in Alice By Jenna Hayes May 2010.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University July 19, 2007.
Tutorial on Kangaroo visiting his animal friends - parameters, events Susan Rodger Duke University June 2009.
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.
Learning to Program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Skater World: Part Three By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009.
Skater World: Part Four By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1, 2009.
An Introduction to Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University, June 2009 Updated June 2014 by Ellen Yuan.
BDE tutorial By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 13, 2008.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Illuminating Computer Science CCIT 4-6Sep
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.
Tutorial on Bunny visiting his animal friends - parameters, events for Alice 3 Susan Rodger Duke University June 2009 Updated by Yossra Hamid on October.
Jonathon Kuo Under the Direction of Dr. Susan Rodger
A Simple Quiz for Alice 3.2:
Alice 3 Programming Assessment: Inheritance
Teaching Characters to Walk: Learning Methods, Part 1
Changing Camera Views! Part 1: Set Point of View to By Bella Onwumbiko
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Tutorial on Kangaroo visiting his animal friends - parameters, events
A Simple Quiz for Alice 3.2:
Methods Tutorial: Part Two
Making Objects Move in Unison: Using Lists
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Checking for Collisions: Using Functions in Alice
An Introduction to Alice
Getting Started With Alice
Professor Susan Rodger
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
Making Objects Move in Unison: Using Lists
Alice Programming Assessment: Inheritance
Presentation transcript:

Creating a Fancier Chicken to use in several worlds - Inheritance Susan Rodger Duke University June 2009

Creating a fancier chicken This tutorial shows you how to add methods, change properties, and add events to the chicken to make a fancier/smarter chicken. Then save out this fancier/smarter chicken and read it into another Alice world. All the properties, methods and events will go with this fancier chicken. Creating a smarter/fancier chicken is called “inheritance”. The modified chicken has new things it can do, plus it “inherits” what the standard Alice chicken can do.

Start - Add a chicken to your world Pick any background (I picked grass). Add a chicken to your world (in the Animals folder) First, we will double the size of the chicken. Right click on the chicken word in the object tree and select “methods”, “resize”, “2”.

Change the chicken’s color to Red Click on Chicken (in the object tree), then properties. Click on the white color beside the color property and select “red”. By changing the property here, the chicken’s color is changed permanently

Now we will create methods for this talented chicken First we will teach him how to jump. Under “Chicken”, then “methods”, click on “create new method”

Name the method “jump” We will now teach the Chicken how to jump.

Chicken move up and down 1m In the “jump” method, have the chicken move up and down 1 meter. How to have the distance to be a choice? Click on create new parameter on the right

Add Distance parameter Name is “distance, type is “Number.” Then drag “distance” over the “1 meter” in your program

The result is: In “world.myFirst Method”, try out the Chicken jump method

Add a Flamingo in the world In the “Animals” folder, add a flamingo to your world. Resize the flamingo by 2. Write a Chicken method to go around the flamingo. Click on “chicken” in the object tree, then on the Chicken method tabs, then “create new methods”

Name the Chicken method “goAround” Add code to have chicken go around flamingo However, what happens if we save this Chicken and put it in a world with no flamingo? Yikes! Alice will crash!

Add an “object”parameter Name the parameter “objectToCircle” and select type “object”

Replace “flamingo” by clicking and dragging “objectToCircle”over flamingo a

Try out new code In world.myfirstmethod, have the chicken circle around the flamingo.

Add a Chicken Event We will create an event that is a “Chicken” event DO NOT click on “Create New Event”! Instead, click on the word Chicken in the object tree and drag it into the Event window, then select “when a key is typed”

Set up the Chicken Event Notice the word “Chicken” before the new event. Click on “any key” and select “letter”, then “S” Drag “Chicken turn” into the Nothing and select right 1 revolution (see next page)

Resulting Chicken Event Because this event is a “Chicken” event, it will be saved out with the Chicken NOTE: If you add a new event for the Chicken, but don’t create it by dragging the object into the event window, then it will default to a world event and will not save out with the Chicken.

Let’s rename our talented Chicken In the object tree, right click on “Chicken”, select “rename” and rename the Chicken to “TalentedChicken” RESULT:

Now save out the TalentedChicken In the object tree, right click on “TalentedChicken”, select “save object” The object is saved in a file called TalentedChicken.a2c

Start a new Alice world with sand To put the chicken in this world, click on “File”, then “import” Browse to where you stored “TalentedChicken. a2c” and import it into your world.

Add Chicken from the local Library Note the chicken you saved is red, and twice as big as the Alice Chicken. Also note the methods you wrote, jump and goAround, and the Chicken Event, are also there. Note the code you wrote in myFirstMethod is not there! Only items related to Chicken properties and methods are saved with the TalentedChicken

Add a cow Fill in the code in myFirstMethod to have the chicken jump twice and goAround the cow.