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.

Slides:



Advertisements
Similar presentations
Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Advertisements

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.
PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU.
Don Slater Wanda Dann
Implementation with procedural methods. Recall: Step 3 Write statements (code) – a few steps at a time, not the entire program at once! Problem Statement.
Don Slater Wanda Dann
Stepwise Refinement -- A procedure calls another procedure
Introduction to Programming with Alice.  Learning how to program in the context of animation, simulation, storytelling, and building short games.  Learn.
Programming in Alice Chapter 2. Today’s Agenda Designing a Program Writing Methods Executing Instructions Simultaneously Comments Tips for Setting Up.
Programming in Alice Chapter 2 Part 2. Events Editor Identifies what method is executed (run) when the “Play” button is hit 2.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Problem Solving with Alice 2 & Friends.
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.
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.
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.
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
Copyright ©: SAMSUNG & Samsung Hope for Youth. All rights reserved Tutorials Software: Building apps Suitable for: Advanced.
Tutorial for Arrays and Lists By Ruthie Tucker. Description This presentation will cover the basics of using Arrays and Lists in an Alice world This presentation.
CS320n –Visual Programming Introduction to Alice Mike Scott (Slides 2)
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
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.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Chapter 1 - Getting to know Greenfoot
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
Animation Programs: Scenarios and Storyboards Alice.
Variables & Random Number Generation.  A penguin is playing arctic basketball. The penguin has a basketball and will push the basketball toward.
Alice Program Design and Implementation. Scenarios and storyboards The previous magician example illustrated a simple storyboard which depicts a scenario.
Don Slater Wanda Dann
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.
Storyboarding1 Steve Cooper Barb Ericson August 2009 Storyboarding.
Don Slater Wanda Dann Copyright 2012 Wanda Dann, Don Slater All rights reserved.
Alice 3.0 A Guided Tour Mike R-D YRDSB. Agenda General Walkthrough of Alice 3.0 Loops, Variables, Threads Methods / Properties Arrays Misc.
The Essentials of Alice Mrs. Jayne Slease SBMS CTE Computer Science and Animation Credit to Duke Students under the direction of Professor Susan Rodger.
Review for test! Alice Chapter 1&2 Test is tomorrow! - March 26 th March 25th.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
Learning to Program with Alice September 22, 2009.
Alice: A Free 3D Animation World for Teaching Programming.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Programming in Alice IT-IDT-9 Design, develop, test and implement programs using visual programming. 9.1 Utilize drag and drop software to develop programs.
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
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.
The Essentials of Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University May 2009.
Alice in Action with Java Chapter 1 Getting Started with Alice.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
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.
1 Quiz Show Programming Terms. 2 Alice - 3D Virtual Programming Vocabulary Quiz Board Chapter 1 Chapter 2a Chapter 2b Chapter 3 Chapter 4 $100 $200 $300.
Jonathon Kuo Under the Direction of Dr. Susan Rodger
Programming in Alice Chapter 2.
A Simple Quiz for Alice 3.2:
Creating Animations in Alice
Teaching Characters to Walk: Learning Methods, Part 1
Getting started in Alice
Introduction to Events
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Programming using Alice 3
Classes, Objects, and World-level Methods
Class-level Methods Alice.
Creating an Animation Program
Alice in Action with Java
Making Procedural Methods
A Simple Quiz for Alice 3.2:
Design and Implementation
Class-level Methods and Inheritance
Presentation transcript:

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  Essential Skill: Gather and organize information and data 2

What is a computer program?  A program is a sequence of instructions that  tell the computer what to do  tell another human being what you want the computer to do  Programs are written for various kinds of tasks (not mutually exclusive)  solve a problem  simulation  game  animation 3

What are statements?  A statement is a written instruction  Three basic kinds of statements  Action to be performed (executes when the program is run)  Control (determines the sequence in which actions are performed)  Comment (documentation of who wrote the program and what the program is intended to do)  The methods panel contains tiles for creating program statements 4

What are methods?  Actions that are placed in a specific order, generally inside of a control of some type.  Class or object methods  things like move, say, turn, roll  Scene level methods  fog density, background color, etc… 5

More on methods  Alice has two types of methods:  Procedures: methods that perform an action  Functions: methods that ask a question  Calling a method: bennyBunny.move(10);  When you write this line of code you are calling the “built-in” procedure “move”. It is a method of the Hare class, which it inherits from the Object class.  10 is an argument or parameter which tells the Hare how far to move 6

Procedural methods  All objects in Alice have built-in procedures  Procedures are methods that perform actions  Move, turn, roll, turnToFace, etc…..  Some procedures are built-in -- part of the Alice 3 system when you install it.  You (as the programmer) can write your own procedural methods. We say these methods are user-defined. 7

Let’s write a simple program  Create a world using the grass template  Add an instance of the Hare (in the Biped folder)  Position the hare so he is in the middle of the screen and standing on the grass  Let’s make the hare jump up and down 8

A Little More Complicated Example 9

Explanation of components in card program:  Control Elements:  Do in order-perform actions in sequence  Do together- perform actions at same time  Analogy: sports track  Do in order—one runner on track  Do together—adds other runners on separate tracks 10

Explanation of components in card program:  Comments are used to document:  your program  Identify the author  Describe the problem/task  Methods (procedures and functions) that you write  Simple description of what the procedure/function does (10-15 words)  Special considerations for use of the method  Required comments for ALL projects for the remainder of the semester:  Name  Description of problem/task (10-15 words)  Brief description in any user-defined methods (10 – 15 words) 11

Classwork  Add another object to your scene with the hare  Write some code to make the two objects perform actions together and separately  You might want to try having subparts perform an action (like raising an arm or kicking a leg) 12

Days 2-3: Writing a program  Objective: Understand the need for step-by-step logic; Basic working of a computer  Essential Skill: DM1- Use technology to advance creative thinking and construct knowledge 13

Programming Problems  Examples presented in this course and assigned in projects are problems, worded like this:  "Write a program to create an animation, where a …“  The problem is: how to write a program “to create an animation, where a...”  Example: Create an animation for the following short film:  A penguin has discovered a bowling ball and a pin in a crate that washed up on the arctic ice. The animation you are to create will show the penguin learning to bowl. The penguin moves forward to the bowl ball. Then, the penguin swaggers left and right, as he considers how to make the ball roll toward the pin. He decides to try pushing the bowling ball toward the pin. When the ball moves forward, it successfully knocks the pin over. Surprisingly, the pin stands up, shakes itself off and pushes the bowling ball back at the penguin. Then the penguin is knocked over! 14

Step 1: Understand the Problem Problem Statement Understand the problem Implement the design Test the Code Design a solution Identify the objects (characters / props) Identify the actions 15

Step 1: Understand the Problem  Need to understand  What characters and props (nouns) are needed?  The penguin moves forward to the bowl ball. Then, the penguin swaggers left and right, as he considers how to make the ball roll toward the pin. He decides to try pushing the bowling ball toward the pin.  What actions (verbs) are performed?  The penguin moves forward to the bowl ball. Then, the penguin swaggers left and right, as he considers how to make the ball roll toward the pin. He decides to try pushing the bowling ball toward the pin. 16

Step 2: Design Problem Statement Understand the problem Implement the design Test the code Design a solution Develop an algorithm (storyboard) Set up the scene 17

Step 2: Design  Set up the scene  Create algorithm  Just like architects/engineers create blueprints, animators create storyboards  Storyboard: 18 Penguin pushes the ball Sound: none Text: none Ball strikes the pin Sound: none Text: none Pin stands up Sound: “Thunk” Text: none

Step 2: Design an Algorithm  Make a “to-do” list of the storyboard actions to be animated  Programmers call this an algorithm  Usually more detailed than sketches or screen captures 19 Do in order penguin move forward (to the ball) penguin swagger penguin push 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

Step 3: Implement the Design 20 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

Step 3: Implement the design  Implementation is the act of translating an algorithm/storyboard into a computer program.  To translate:  Decompose algorithm step by step  Incrementally develop and test program statements  Not all at once, but a few steps at a time!  To create a statement, drag a code tile into the edit space  Lets make the penguin move towards the ball! 21

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

Step 4: Test and Revise  When Run… button is clicked  Alice builds the scene for the runtime window  Executes the program statements, starting with the myFirstMethod procedure (defined in MyScene) 23 Runtime window

Creating your own procedures!  We moved towards the ball, now lets make the penguin swagger  But problem—swagger isn’t a tile in the procedures!  Built in procedures are simple actions.  We will need to create our own procedure made up of multiple simple actions  Lets decompose the “swagger” procedure: 24 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

The Class Tab  Select Penguin from Class Menu  Select the Penguin class tab  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  Lets add a procedure by clicking on the Add Procedure button in the procedures section 25

Procedure Names  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/other symbols  Start with a lower case letter  Use camelCase if more than one word is desired  Two or more classes may have procedural methods with the same name but the actions may be different  Penguin has a swagger side to side  Pin might also have a swagger front to back 26

Procedure swagger 27 “this” is a proxy – “stands in for” the name of any penguin object (instance of the Penguin class) in your project scene, whatever penguin calls the procedure

Comments for the Procedure  Documentation for procedures  Assumes: Assumptions made regarding conditions prior to calling the procedure  Action: description of the procedure action  Postcondition, if any  In-line comments: More specific comments may be imbedded in the code, to help other programmers understand what the code is intended to do 28

Implement swagger  Using our design as a guide, drag tiles into the swagger code editor  Final code: 29 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  Return to the Scene Class and Click on the Run button  What happens and why?!? 30

We need to call swagger in myFirstMethod  We defined the new procedure, swagger; but, we also need to call it somewhere in our program  Select penny in the instance menu  Drag the swagger tile into myFirstMethod in the editor  Now test again 31

Classwork  One final hint: for quick access to the Add Procedure button: 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  Now finish the penguin and bowling program! 32 Start by clicking here

Days 4-5: Project 2.1  Project description and requirements posted on website 33

Day 6: Unit 2 Quiz  20 points  Multiple Choice  True/False  Short Answer  Material comes from this PowerPoint and in class discussions 34