Programming: Putting Together the Pieces Built-in Questions and Expressions Alice.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Decision Structures Chapter 4. Chapter 4 Objectives To understand: o What values can be stored in a Boolean variable o What sequence structures are and.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Built-in Functions & Arithmetic Expressions.
Events Chapter 7. Interactive Real world is interactive User determines order of actions instead of programmer.
Programming: Simple Control Structures Part 1 – Conditional Execution Alice.
Functions and Visual Effects Chapter 6 Part 3. Built-in Functions We have been using built-in functions so far 2.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Classes, Objects, and World-level Methods Alice. Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics.
Functions and Conditionals in Alice 1 Stephen Cooper Wanda Dann Barb Ericson September 2009.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
Execution Control with If/Else and Boolean Questions Part 1 Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
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.
Creating An Animation Program Part 2 Alice. Method A segment of program code (instructions) that defines how to perform a specific task.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Four Fundamental Pieces Instruction Control Structure Function Expression.
Writing Our Own Functions Alice. Functionality A function receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Functions Alice.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Variables and Functions Alice. Naming is Important If you get a new pet one of the first things you do is name it Gives you a way to refer to the new.
Functions Sec 8-11 Web Design. Objectives The Student will: Understand what a function is Know the difference between a method and a function Be able.
Today’s Agenda 1.Collect Pre-Lab 3 2.Alice Programming Assignment 3.Built-in Functions 4.Expressions 5.Control Structure 6.Assign pair programming teams.
Programming: Simple Control Structures
Questions Alice. Functionality A question receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Interactive Programming Alice. Control of flow Control of flow -- how the sequence of actions in a program is controlled. What action happens first, what.
Obj: Programming: Simple Control Structures HW: Read section 3 – 2 AC3 D2 Do Now: 1.Log on to Alice. Open the file firstEncounter.a2w located in the folder.
Programming: Simple Control Structures Sec 46 Web Design.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Programming: Putting Together the Pieces Built-in Functions and Expressions Sec 8-5 Web Design.
Obj: to recognize built-in functions and expressions HW: Read Section 3.1 and do HW4 Edmodo article due Sunday at 8pm Edmodo feedback due 8pm 10/17 Do.
Programming: Putting Together the Pieces Built-in Functions and Expressions Sec 8-5 Web Design.
Functions Sec 51 Web Design.
Programming: Simple Control Structures
Chapter 3: Variables, Functions, Math, and Strings
Programming: Simple Control Structures
Simple Control Structures
Functions Sec 8-11 Web Design.
Repetition Control Structures
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Programming: Simple Control Structures
Programming: Simple Control Structures
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Programming: Simple Control Structures
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Functions Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Programming: Simple Control Structures
Relational Operators.
Execution Control with If/Else and Boolean Questions Example: Multiple Conditions Alice.
Functions Alice.
Programming: Simple Control Structures
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Class-level Methods and Inheritance
Functions Alice.
Execution Control with If/Else and Boolean Questions Example: Multiple Conditions Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Execution Control with If/Else and Boolean Questions Example: Multiple Conditions Alice.
Functions Alice.
Class-level Methods and Inheritance Part 2
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Presentation transcript:

Programming: Putting Together the Pieces Built-in Questions and Expressions Alice

Putting together the pieces A major part of learning how to program is figuring out how to "put together the pieces" that compose a program. The purpose of this lecture (and the next) is to show some primary pieces used in creating programs demonstrate how to put the pieces together

Four Primary Pieces Instruction Control Structure Question Expression

Instruction An instruction is a statement that executes (is carried out by the computer at runtime). In Alice, an instruction makes objects perform a certain action. Examples: snowman turn to face snowwoman helicopter turn left 0.25 revolutions

Control Structure A control structure is a statement that controls which statements are executed and in what order. Examples: Do in order Do together

Questions A question is a function that checks a condition or computes a value. In Alice, you can ask questions about the properties of objects Is the snowwoman's face red? the relationship of one object to another What is the distance between the mummy and pyramid? the world What key (on the keyboard) was pressed? Let's look at an example…

Problem Example A Hollywood movie set. The camera angle influences our perception of the scene. Is the mummy taller than the pharaoh? How far is the mummy from the pharaoh?

Built-in Questions The Alice system provides some built-in questions. Categories proximity size spatial relation point of view other This example illustrates some built-in proximity questions.

Values An answer to a question is a value. The type of value depends on the kind of question asked. In our example, we want to ask the question: What is the distance of the mummy to the pharaoh? We expect to get a number value. It could be a whole number or a fractional value, such as 3 meters or 1.2 meters

Demo A program will be developed in class to illustrate the use of a question to move the mummy to the pharaoh.

Code Note that the question "piece" of the program does not "stand alone." In this example, the question is part of a move instruction The value provides the distance the mummy will move.

Types of Values In our example, we used a question that has a number value. Other types of values include: Boolean true, false String "Oh, Yeah!" Object snowman, helicopter Position in the world (0, 0, 0) – the center of an Alice world

Problem: Collision When the program is run, the mummy collides with the pharaoh. The problem is the distance between two objects is measured center-to-center. One way to avoid a collision is to subtract a small number (perhaps 1) from the distance.

Expressions An expression is a math or logic operation on numbers or other types of values Alice provides math operators for common math expressions: addition + subtraction  multiplication * division /

Demo A modification of the program to illustrate the use of an expression.

Assignment Read Chapter 3-1, Questions and Expressions Lab 3-1