Fall 2007ACS-1805 Ron McFadyen1 Chapter 3 Programming.

Slides:



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

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
1 Fall 2009ACS-1805 Techniques for designing code Storyboards Text (aka pseudocode) Diagrams Flowcharts (a procedural technique shown in text) Directed.
Fall 2007ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
Fall 2009ACS-1805 Ron McFadyen1 Functions A function is a collection of statement, similar to a method, but a function is defined to return a value to.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs.
Fall 2007ACS-1805 Ron McFadyen1 Functions and if-else A function is a collection of statement, similar to a method, but a function is defined to return.
Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
1 Fall 2008ACS-1805 Techniques for designing code Storyboards Text (aka pseudocode) Diagrams Flowcharts (a procedural technique) Text presents one of these.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 7 Repetition.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 3 Programming - Putting Together the Pieces.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 8 Recursion.
Fall 2008ACS-1805 Ron McFadyen1 Ch 8 Recursion Recursion occurs when a method (or function) calls itself.
Fall 2009ACS-1805 Ron McFadyen1 ACS-1805 Introduction to Programming using Alice.
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.
Fall 2009ACS-1805 Ron McFadyen1 Ch 8 Recursion Recursion occurs when a method (or function) calls itself.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 4 OO Programming Concepts.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 6 Functions & If/Else.
Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Creating An Animation Program Alice Web Design Section 8-4.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
1 Ch. 7 Recursion similar to iteration in that you repeatedly do a little bit of the task and then “loop” again and work on a smaller piece - eventually.
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.
1 Fall 2007ACS-1903 Techniques for designing code Storyboards Text (aka pseudocode) Diagrams Flowcharts (a procedural technique) Text presents one of these.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Programming: Simple Control Structures Part 2 – Repetition Alice.
CSE 425: Control Flow I Categories of Control Flow Constructs Sequencing –order of expressions and statements Selection –if, else, switch Iteration –loops.
Programming: Putting Together the Pieces Built-in Questions and Expressions Alice.
Creating an Animation Program
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Fall 2009ACS-1805 Ron McFadyen1 Chapter 2 Program Design & Implementation.
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
Programming: Simple Control Structures MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 2 Creating Your First Animation (An Introduction to Programming)
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
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.
Animation Programs: Scenarios and Storyboards Alice.
Programming: Simple Control Structures Sec 46 Web Design.
Fall 2008ACS-1805 Ron McFadyen1 Event-driven programming Chapter 5 covers event-driven programming. Events are user or condition driven and so each event.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 4-1 Lecture Objectives To understand: –what values can be stored in a Boolean.
Today… Python Keywords. Iteration (or “Loops”!) Winter 2016CISC101 - Prof. McLeod1.
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.
Programming: Simple Control Structures
Programming: Simple Control Structures
Simple Control Structures
Programming: Simple Control Structures
Creating an Animation Program
Programming: Simple Control Structures
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Java Programming Control Structures Part 1
Programming: Simple Control Structures
Programming: Simple Control Structures
Graphical User Interfaces in Java Event-driven programming
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Programming: Simple Control Structures
Event-driven programming
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.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Presentation transcript:

Fall 2007ACS-1805 Ron McFadyen1 Chapter 3 Programming

Fall 2007ACS-1805 Ron McFadyen2 Programming Fundamentals Chapter 3 introduces the fundamentals of programming. Construction of a program usually requires us to include: Simple instructions Control structures Functions Expressions

Fall 2007ACS-1805 Ron McFadyen3 Simple instructions Simple instructions; examples: Commanding an object to carry out one of its actions Assigning a property a value

Fall 2007ACS-1805 Ron McFadyen4 Control structures Control structures: These affect the sequence of execution. Alice offers several types: Do together Do in order If/Else Loop While For all in order For all together

Fall 2007ACS-1805 Ron McFadyen5 Control structures The “mana” exercise used 2 of these:

Fall 2007ACS-1805 Ron McFadyen6 The Pieces Functions These are used to obtain certain calculations Each object has a set of pre-defined functions Proximity Size Spatial relation Point of view other

Fall 2007ACS-1805 Ron McFadyen7 The Pieces Expressions Certain information needed for a simulation may require us to calculate things using arithmetic E.g. the distance from the centre of the robot to the centre of the rock

Fall 2007ACS-1805 Ron McFadyen8 Examples Consider the rock, alien and robot in the First Encounter. We shall extend the world from an earlier class and demonstrate Simple instructions Functions Expressions Do together If/else Loop

Fall 2007ACS-1805 Ron McFadyen9 Example Instead of having the robot move towards the alien, we can have the robot move towards the rock that is in front of the alien A simple instruction can command the robot to move towards the rock:

Fall 2007ACS-1805 Ron McFadyen10 Example Consider the rock and the robot We can do better than moving 1 metre, we can move the robot an appropriate distance determined via a calculation how far apart are they? how far should the robot move? Consider:

Fall 2007ACS-1805 Ron McFadyen11 Example Consider the rock and the robot We need the robot to be walking towards the rock Using the Do Together control structure we have the moving and walking occurring at the same time

Fall 2007ACS-1805 Ron McFadyen12 Example Suppose we want the robot to look toward the alien. But if the robot is shorter than the rock we could have the robot raise its head a bit If the robot is shorter than the rock we want the robot to raise its head, otherwise it doesn’t have to We can use an If/Else control structure:

Fall 2007ACS-1805 Ron McFadyen13 Example Consider the rock and the robot Previously we had the robot walking to the rock, but the robot took 1 step with each of 2 legs regardless of the distance. Suppose we want the walking effect to appear with each metre travelled – we can use a Loop: See next slide for a more advanced “times” calculation

Fall 2007ACS-1805 Ron McFadyen14 Example Consider the rock and the robot An expression to calculate the number of times to move a single metre: