Implementation with procedural methods. Recall: Step 3 Write statements (code) – a few steps at a time, not the entire program at once! Problem Statement.

Slides:



Advertisements
Similar presentations
Intro to Computers!.
Advertisements

Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Don Slater Wanda Dann
Developing an Excel Application
Tutorial 8: Developing an Excel Application
Don Slater Wanda Dann
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Stepwise Refinement -- A procedure calls another procedure
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.
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,
Creating a 3D Interactive Story Prof. Susan Rodger Duke University Feb. 24, 2007.
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.
Key Applications Module Lesson 12 — Word Essentials
Conversational Computers
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Adobe Forms THE FORM ELEMENT PANEL. Creating a form using the Adobe FormsCentral is a quick and easy way to distribute a variety of forms including surveys.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
05/09/ Introducing Visual Basic Sequence Programming.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
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-
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Adobe Flash CS4 – Illustrated Unit C: Using Symbols and the Library Panel.
Lesson 1 Windows 7. Windows 7 is an operating system. The main screen is called the Windows Desktop.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
Variables & Random Number Generation.  A penguin is playing arctic basketball. The penguin has a basketball and will push the basketball toward.
Creating Buttons – Lesson 51 Creating Buttons Lesson 5.
Learning Unity. Getting Unity
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
Click your mouse to continue. The Office Shortcut Bar The Office Shortcut Bar contains program buttons that, when clicked, start new documents or start.
Game Maker – Getting Started What is Game Maker?.
Word wrap: a feature in word processors which causes the insertion point to automatically jump down to the beginning of the next line when you reach the.
Don Slater Wanda Dann Copyright 2012 Wanda Dann, Don Slater All rights reserved.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET Part I VB.NET Controls VB.NET Events.
Medical. Step 1 Your User ID is your City network login which must be typed in ALL CAPITAL LETTERS. Enter the desired information into the User ID field.
Alice 3.0 A Guided Tour Mike R-D YRDSB. Agenda General Walkthrough of Alice 3.0 Loops, Variables, Threads Methods / Properties Arrays Misc.
Dreamweaver MX. 2 Tools for Code Editing (p. 366) n An HTML editor like Dreamweaver writes most of the code you need, but at times you will need to perform.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University July 19, 2007.
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.
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Adding and Eating Worms Mrs. C. Furman August 23, 2010.
How Tall Are You? Introducing Functions for Alice 3 By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Unit 2 Programming in Alice & Java 1. Day 1: Learning to Program  Objective: Understand the need for step-by-step logic; Basic working of a computer.
Chapter 2: Programming in Alice
UNIT 1: Introduction To The AutoCAD Interface Objectives: Be able to identify, describe and/or apply… The key components of AutoCAD interface The AutoCAD.
Key Applications Module Lesson 12 — Word Essentials Computer Literacy BASICS.
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.
Microsoft Word 2016 Lesson 3.
A Simple Quiz for Alice 3.2:
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Repetition Control Structures
Microsoft Office Illustrated
Introduction to Events
Hands-on Introduction to Visual Basic .NET
Making Procedural Methods
A Simple Quiz for Alice 3.2:
Key Applications Module Lesson 12 — Word Essentials
Key Applications Module Lesson 12 — Word Essentials
Microsoft Excel 2007 – Level 2
Presentation transcript:

Implementation with procedural methods

Recall: Step 3 Write statements (code) – a few steps at a time, not the entire program at once! Problem Statement Understand the problem Implement the design Test the code Design a solution Decompose into simple steps

Recall: we created a statement  A statement is created by dragging a code tile into the edit space

Do in order penguin move forward (to the ball) penguin swagger penguin pushes the bowling ball so it rolls to the pin pin falls over pin responds (stands up and pushes the ball back to penguin) penguin falls over Penguin swagger  Where is the swagger?

Built-in procedures are simple actions. The penguin doesn’t have a swagger procedural method -- swagger is a complex action that combines several simple actions. Built-in procedures

Decomposition of swagger penguin swagger Do in order // penguin shift side to side penguin roll left penguin roll right 0.25 penguin roll left //penguin jump up and down penguin move up 0.5 penguin move down 0.5 Do in order penguin move forward (to the ball) penguin swagger penguin pushes the bowling ball so it rolls to the pin pin falls over pin responds (stands up and pushes the ball back to penguin) penguin falls over

1. Select Penguin from Class Menu 2. Select the Penguin class tab Open class tab 1 2

 The class document shows all the methods (procedures & functions) and properties of the class Can add, edit, or delete procedures, functions, or properties in a class document Class tab

Click the Add Procedure button… in the procedures section Add a procedure

Type in a name for the new procedure  Naming rules ◦ Begin with an alphabetic character, not a digit ◦ A name consists of letters, digits or underscore “_”, no spaces or other symbols ◦ Naming conventions ◦ Start with a lower case letter ◦ Use camelCase if more than one word is desired

Procedure names in classes Two or more classes may have procedural methods that have the same name Penguin has a swagger Pin might also have a swagger Even though the names may be the same, the actions performed may be different Example Penguin swagger is side to side Pin swagger might be front to back

Procedure swagger

this  “this” is a proxy – “stands in for” the name of any penguin object (instance of the Penguin class) in your project scene

Documentation for procedures – Assumes: Assumptions made regarding conditions prior to calling the procedure – Action: description of the procedure action – Postcondition, if any

More specific comments may be imbedded in the code, to help other programmers understand what the code is intended to do In-line Comments

 Using our design as a guide, drag tiles into the swagger code editor. Implement swagger penguin swagger Do in order // penguin shift side to side penguin roll left penguin roll right 0.25 penguin roll left // penguin jump up and down penguin move up 0.5 penguin move down 0.5

Step 4: Test Problem Statement Understand the problem Implement the design Test the code Design a solution Does it work, no matter what? Try different values (distance, direction, revs)

Test Click on Run button Return to Scene class

What happens? Nothing!!! Why?

Call swagger in myFirstMethod 1.Select penny in the instance menu 2.Drag the swagger tile into myFirstMethod in the editor We defined the new procedure, swagger But, we also need to call it somewhere in our program 1. 2.

Test again We should see the penguin swagger

1. Click on the Class Menu button 2. Select Penguin from Class Menu in the Code Editor 3. Select Add Procedure… from the Penguin class submenu Start by clicking here Hint: Quick access to Add procedure button 2 3 1