CS320n –Visual Programming Classes, Objects, and World- Level Methods Mike Scott (Slides 4-1)

Slides:



Advertisements
Similar presentations
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Advertisements

Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
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 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)
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
World-level Methods with Parameters Alice. Larger Programs As you become more skilled in writing programs, you will find that your programs quickly begin.
CS320n – Elements of Visual Programming Introduction to Alice Mike Scott (Slides 1-1)
Exploring Events. Try this Start Alice and create a blank world using the grass template. Add an instance of a BlueBallerina. Add an instance of a PinkBallerina.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Alice: A Visual Introduction to Programming Chapter 1 Part 2.
CS320n –Visual Programming Interactive Programs Mike Scott (Slides 5-1)
Classes, Objects, and World-level Methods Alice. Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics.
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.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University Feb. 24, 2007.
Methods Tutorial: Part One By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 9, 2008.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Classes / Objects / Methods
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
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.
CS320n –Visual Programming Introduction to Alice Mike Scott (Slides 2)
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
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.
Animation Programs: Scenarios and Storyboards Alice.
Getting started with Alice Adapted from presentations by Jenna Hayes, Duke University Donna Gavin, UWP Computer Science and Software Engineering.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
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.
Xin Nov 15, Introduction to Alice Alice A very visible programming language Programming by dragging objects Interface World window The virtual world.
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.
The Essentials of Alice (Bunny) By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
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.
Storyboarding and Program Design Alice. Step 1: Design Decide on the problem to be solved Design a solution We will use a storyboard design technique,
Creating a 3D Interactive Story Prof. Susan Rodger Duke University July 19, 2007.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
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. The programming steps.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Animation Programs: Scenarios and Storyboards Alice.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Using Placeholders to Simplify your Methods: Learning Methods, Part 2 By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
Presenter: Carol Liss Timberlane Regional Middle School 6 th and 7 th grade Tech. Educator Co presenters:
The Essentials of Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University May 2009.
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
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
World-level Methods with Parameters
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
Classes / Objects / Methods
Classes, Objects, and World-level Methods
Presentation transcript:

CS320n –Visual Programming Classes, Objects, and World- Level Methods Mike Scott (Slides 4-1)

Visual ProgrammingClasses, Objects, and World Level Methods 2 What We Will Do Today Look at ways of doing the fish problem from last time Define Classes, Objects, and Methods in Alice Define and create world level methods more complicated snowman movie

Visual ProgrammingClasses, Objects, and World Level Methods 3 Fish Circling Around Island Smooth Jagged Play Movie

Visual ProgrammingClasses, Objects, and World Level Methods 4 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. –Fish program about 30 already –How many things can you keep in short term memory? Games and other "real world" software applications can have thousands, even millions of lines of code. Want to organize large programs into small manageable pieces –big rocks into little rocks

Visual ProgrammingClasses, Objects, and World Level Methods 5 Classes, Objects, and Methods Alice uses classes, objects, and methods as basic programming components. –it is just one way to think about programming object oriented –there are many others These components help you to – organize a large program into small pieces – design and think about an intricate program – find and remove errors (bugs)

Visual ProgrammingClasses, Objects, and World Level Methods 6 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. Class: Fish (Uppercase name) Objects: fish, fish1, fish2, fish3 (lowercase names)

Visual ProgrammingClasses, Objects, and World Level Methods 7 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…

Visual ProgrammingClasses, Objects, and World Level Methods 8 Snowman Program

Visual ProgrammingClasses, Objects, and World Level Methods 9 Snowman Program

Visual ProgrammingClasses, Objects, and World Level Methods 10 More on the Snowman Program Snowwoman blushes and then turns back to her friend Snowman turns away and shakes his head Show Movie

Visual ProgrammingClasses, Objects, and World Level Methods 11 Modifying the program Modify program to get snowman to try to get snowwoman’s attention twice To make this modification must add more lines of code –program getting longer, more complicated, more difficult to think about and understand, harder to make changes –program is suffering a “code explosion” Show movie of trying to get attention twice

Visual ProgrammingClasses, Objects, and World Level Methods 12 Try twice to get attention Notice the wait command in between the two attempts to get the snowwoman’s attention –wait is one of the commands at the bottom of the method editor

Visual ProgrammingClasses, Objects, and World Level Methods 13 Why is this “Bad”? Not hard to copy and paste code, right? Easy to simply say “make copy” of the Do together block and insert a wait … but, getting a little harder to maneuver around the program with all that code … and what if we want to change something about the getting attention behavior? –blink eyes twice or change duration of blink

Visual ProgrammingClasses, Objects, and World Level Methods 14 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

Visual ProgrammingClasses, Objects, and World Level Methods 15 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

Visual ProgrammingClasses, Objects, and World Level Methods 16 Demo A demonstration of writing the catchAttention method

Visual ProgrammingClasses, Objects, and World Level Methods 17 World-level method catchAttention is a world-level method because it -is defined as a method for World if the method has instructions that involve more than one object it must be a world level method This method only involves the snowman so we could have made it a method for the snowman

Visual ProgrammingClasses, Objects, and World Level Methods 18 Using the catchAttention method The catchAttention method is executed by calling (invoking) the method from my first method

Visual ProgrammingClasses, Objects, and World Level Methods 19 Testing Method Independently Can test method by adding event to the program disable other methods

Visual ProgrammingClasses, Objects, and World Level Methods 20 Why? Why do we want to write our own methods? – saves time -- we can call the method again and again without reconstructing code –Easy to make changes to behavior only have to change in one place – 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 “say “Toot” moving eyes up and down" the technical term for "think at a higher level" is "abstraction"

Visual ProgrammingClasses, Objects, and World Level Methods 21 Exercise for Class Do problem Chapter 4, exercise 2, Confused Kanga on page 110 of the book –see web for description