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.

Slides:



Advertisements
Similar presentations
Mike Scott University of Texas at Austin
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.
Created: June “Myth” of programming is too hard out of the equation Students have a visual of what “their” program is doing Syntax frustration.
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.
CSC1401 Animation Creating methods/instructions (class-level)
Parameters and World-level methods Alice. Our Dragon world The dragon must to take off and fly, to carry the princess.
World-level Methods with Parameters Alice. Larger Programs As you become more skilled in writing programs, you will find that your programs quickly begin.
Parameters Alice.
Parameters Section 8-8 Web Design. Objectives The student will: Understand what a parameter is Understand how to use a parameter in Alice Understand how.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Introduction to Programming with Alice.  Learning how to program in the context of animation, simulation, storytelling, and building short games.  Learn.
Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
Programming in Alice Chapter 2 Part 2. Events Editor Identifies what method is executed (run) when the “Play” button is hit 2.
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,
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.
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Classes, Objects, and World-level Methods
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
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.
Making a Timer 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.
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.
Decision Structures Chapter 4 Part 2. Chapter 4 Objectives To understand o What relational operators are and how they are used o Boolean logic o Testing.
Events Chapter 7 Part 2. While a Key is Pressed Event Specialized event An event occurs when you press a key and continues until you take your finger.
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.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
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.
Review for test! Alice Chapter 1&2 Test is tomorrow! - March 26 th March 25th.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.
Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.
Parameters Alice. A beetle band Our task is to create an animation for a bug band as an advertisement for their next concert.
Parameters Alice. Overview The need for more flexible methods Passing a parameter to a method Demos Using the Alice interface to write code for a parameter.
Parameters MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum redesign project funded.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Using Placeholders to Simplify your Methods: Learning Methods, Part 2 By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
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
Parameters Section 8-8 Web Design.
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
World-level Methods with Parameters
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Parameters Alice.
Classes, Objects, and World-level Methods
Class-level Methods Alice.
Classes, Objects, and World-level Methods
Parameters and World-level methods
Methods Tutorial: Part Two
Chapter 2: Programming in Alice
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
Parameters Alice.
Classes, Objects, and World-level Methods
Class-level Methods and Inheritance
under the direction of Professor Susan Rodger
Class-level Methods and Inheritance Part 2
Presentation transcript:

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 minds Games and other software can have thousands, even millions of lines of code 2

Basic Components Classes, objects, and methods in object-oriented programming help to o Organize a large program into small modules o Design and think about an intricate program o Find and remove errors (bugs) 3

World Level Method Method that can reference entire World Has instructions involving more than one object (cleverSkater, penguin) Class-level methods only involve one object 4

Why Write World Level Methods? No method does what you need o You need new functionality Saves time o Can call method many times without making your own code to do same thing Reduces code size o Call method instead of rewriting code Allows thinking at a higher level o You think of method names instead of what method does  Ex: sharkSwims, sharkEatsFish, etc. o Allows abstraction – "thinking at a higher level" 5

Demo: Starting a new method First 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 6

Edit or Read Method Click on edit button to edit or read method code Can open method by double clicking on it in method editor 7

Example: A Beetle Band Create an animation for a bug band as an advertisement for their next concert 8

Demo BeetleBand-v1 Concepts illustrated o To play a sound, a sound file must first be imported into Alice  Alice is not a sound editor o This code is only for georgeBeetle o Three more methods (one for each band member) will be needed 9

Algorithms: Playing Solo Each bug band member will perform a solo Do together Do in order georgeBeetle move up georgeBeetle move down play sound Do together Do in order ringoBeetle move up ringoBeetle move down play sound Do together Do in order paulBeetle move up paulBeetle move down play sound Do together Do in order lennonBeetle move up lennonBeetle move down play sound 10

A Better Solution Creating four versions of similar code is tedious Only things that change are band member and music played Better solution o Write more flexible method using parameters 11

Beetles Algorithm One method can be used Use parameters to specify  Which band member will perform  Which music should be played solo Parameters: bandMember, music Do together Do in order bandMember move up bandMember move down play music 12

Place bandMember in Method 13 Create bandMember parameter as object Drag bandMember parameter to editor Menu pops up where you can choose method to use

Alice Program for Solo Notice that bandMember is an object parameter Music is a sound parameter 14

Drag solo to Editor Fill in parameters: 15

BeetleBand-v2 New solo method is added for each band member and music to play 16

Demo BeetleBand-v2 Concepts illustrated o Enter name and select type for each parameter  bandMember is an Object parameter  music is a Sound parameter o Arguments passed to parameters in called method  bandMember: georgeBeatle, lennonBeatle, paulBeetle, ringoBeatle  What are the arguments passed into music parameter? o Parameters are placeholders  bandMember and music get new values when called from arguments 17

Homework Read chapter 6 section 7 Do chapter 6b lab. Due next class. 18