Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.

Slides:



Advertisements
Similar presentations
Mike Scott University of Texas at Austin
Advertisements

PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Lesson 7B Creating Our Own Methods Slides are adapted from aliceprogramming.net or
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Exam Wednesday No inclass assignment this week. Friday labs will help with individual homework assignment due Friday midnight Review for exam –Tuesday.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Programming in Alice Chapter 2. Today’s Agenda Designing a Program Writing Methods Executing Instructions Simultaneously Comments Tips for Setting Up.
Chapter 2: Input, Processing, and Output
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 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.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley This week: Whew!!! The last homework was tough! The homework for this week.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
Programming Logic Program Design. Objectives Steps in program development Algorithms and Pseudocode Data Activity: Alice program.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Excel 2010 by Robert Grauer, Keith.
3–D Helium Molecule Tutorial Alice Project Duke University Professor Susan H. Rodger Gaetjens Lezin June 2008.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 3 Simple.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
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 Exam scores by range 3-1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Where are we? Alice is a “toy” language Fundamentals are exactly like “real”
By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 2 Graphics Programming with C++ and the Dark GDK Library Starting.
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.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Alice Workshop November 2009 By: Kim Glavan New Lenox School Dist #122.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Alice 3.0 A Guided Tour Mike R-D YRDSB. Agenda General Walkthrough of Alice 3.0 Loops, Variables, Threads Methods / Properties Arrays Misc.
Review for test! Alice Chapter 1&2 Test is tomorrow! - March 26 th March 25th.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Skater World: Part Four By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1, 2009.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Headshots in Alice Duke University Professor Susan H. Rodger Gaetjens Lezin July 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:
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
An Introduction to Programming Using Alice 2.2, Second Edition Chapter 7 Recursive Algorithms.
Chapter 2: Programming in Alice
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
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.
Programming in Alice Chapter 2.
Chapter 3: Variables, Functions, Math, and Strings
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Chapter 2: Programming in Alice
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Introduction to Object-Oriented Programming in Alice
Presentation transcript:

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition by Tony Gaddis Chapter 4: Programming in Alice

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-2 Chapter 4 Objectives To understand: –method naming conventions –what dot notation is –what a primitive method is and which objects have them –what is meant by “calling” –what an argument is in a program. –differences in naming conventions –the steps of the program development cycle –what a logical error is –the need for commenting

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-3 Today’s Agenda 1.Writing Methods 2.Naming Conventions 3.Designing a Program 4.Comments 5.Tips for Setting Up an Initial Scene 6.Executing Instructions Simultaneously 7.Exporting Your Code for Printing

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-4 Writing Methods What is a method? –set of instructions that execute –create methods by dragging tiles into the Method Editor –these tiles are the instructions my first method 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-5 Naming Conventions dot notation –world.my first method dot (period) separates pieces of information –left side: object that the method belongs to in this case…the method belongs to the WORLD object –right side: name of the method in this case… “my first method” the period is called a “dot” 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-6 world.my first method Events Editor identifies which method plays or is acted upon when the “Play” button is hit 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-7 world.my first method Methods play the instructions (tiles) that are dragged into the Method Editor 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-8 Primitive Methods All objects have a common set of built-in method for performing actions. These “primitive methods” all objects to move, turn, change size, and more. Example: Hare has primitive methods to move, turn, roll, resize, say dot notation: hare.move 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-9 Terminology Calling the method: –executing a method Argument: –piece of information that a method needs in order for it to execute –hare.move…which direction? the direction…up, down, left, right…is the argument Passing the Argument: –the method is called and the arguments are presented objec t method argument editing tag 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-10 Editing Tag Holds additional arguments What appears depends on the method called –duration specifies amount of time for action to take place default (1 second) 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-11 Deleting Right-click the instruction and select delete Drag the instruction tile to the trash can 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-12 Copying Right-click the instruction and select copy Drag the instruction tile to the clipboard –when the clipboard turns green, drop the tile –click on the clipboard and drag it back to the Method Editor 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Custom Methods In addition to primitive methods (the things that ALL objects can do)…some objects have custom methods When objects is selected from gallery, a listing of custom methods appears Names of the custom methods give clues as to what the method does What do you think the foottap custom method does? 2.1

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-14 namingConventions Names are known as identifiers…because they identify items in a program Use a name that provides meaning –Name of method should indicate the method’s purpose 2.2 Which one coaches the Knights and which one coaches the Cougars?

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-15 namingConventions Most programming languages do NOT recognize spaces –Alice allows spaces method.my first method Since spaces are not allowed, how do you combine more than one word in naming? –Capitalize subsequent words –Called camelCase 2.2 Note the space Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Which is easier to read? onehumpcamel or oneHumpCamel

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-16 Class Names method names begin with a lower case letter Class names are capitalized No spaces, so each word is capitalized –This convention is called PascalCase 2.2

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-17 Renaming Objects –Right-click object’s tile in the object tree and select rename. Methods –Select the world object –Select the method’s tab from the Details Panel –Right-click the my first method tile and select rename. 2.2

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-18 Designing a Program Design requires planning…that follows the above steps Called program development cycle Cycle is repeated until there NO errors appear in the program. 2.3 Design the programWrite the methodsTest the methodsDebug the methods

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-19 Designing the Program Determine what the world is supposed to do. Use problem statement that describes the objects that will appear 2.3 Design the programWrite the methodsTest the methodsDebug the methods

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-20 Designing the Program Break the problem statement down into series of steps –Pseudocode –Flowchart 2.3 Design the programWrite the methodsTest the methodsDebug the methods

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-21 Writing the methods Design steps (pseudocode or flowchart) provides model for writing the methods Drag tiles into Method Editor to assemble instructions Instructions should follow the order of the Design steps Pseudocode and flowchart may NOT be at the detail of the final instructions 2.3 Design the programWrite the methodsTest the methodsDebug the methods

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-22 Testing Test to make sure it meets the following criteria: –Does it do what it was intended to do? –Does it have any errors? Or undesired results? –Is it efficient? Are there unnecessary steps? If the criteria are NOT met, then debugging occurs Debugging means to determine what must be corrected or modified to get the program to work correctly. 2.3 Design the programWrite the methodsTest the methodsDebug the methods

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-23 Designing a Program Debugging means to determine what must be corrected or modified to get the program to work correctly Logical errors (bug) is a mistake that produces an incorrect result, but the program still runs. –Instructions in an incorrect order may produce incorrect results –Passing incorrect values as arguments can cause logical errors 2.3 Design the programWrite the methodsTest the methodsDebug the methods

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-24 Comments A comment is a note explaining the code Crucial part of the code Makes the code understandable Alice ignores comments when it plays your program 2.4 // comment tile

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-25 Tips for Setting Up the Initial Scene Use the primitive methods to setup the scene –Select the object in the Object Tree, then select a method Use the primitive methods to position the objects –Doing so from the Object Tree positions the objects outside of the program 2.5

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-26 Tips for Setting Up the Initial Scene Moving an object to the center of the world –Use the move to method and choose the entire world as the method’s argument –Places the object’s center point at the world’s center point of (0, 0, 0) 2.5

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-27 Tips for Setting Up the Initial Scene Positioning objects a specified distance apart –Use the move to method and choose asSeenBy the other object for the method’s argument –Places the object’s center point at the world’s center point of (0, 0, 0) 2.5

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-28 Tips for Setting Up the Initial Scene Moving the camera to an object –Right-click the object and choose Camera get a good look at this –Camera moves to a position so the object is in plain view 2.5

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-29 Executing Instructions Simultaneously By default, instructions are executed one after the order…in the order they appear in the Methods Editor For simultaneous actions, drag Do together into the Methods Editor Other instructions can be place within the Do together tile Make sure the duration for all items in Do together are the same 2.6

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-30 The Do in order Structure By default, all instructions are performed in order they appear in the Methods Editor Do in order structure used when more than one set of actions must occur simultaneously…but has steps that must be done in order 2.6

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-31 Exporting Code for Printing Code can be exported to an HTML file –Open the file and Print From File – Choose Export Code for Printing YOU must add your name as the author –Author’s name is printed with the exported code 2.7 Author’s name