Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:

Slides:



Advertisements
Similar presentations
CS320n –Visual Programming Class-level Methods and Inheritance – Part 1 Mike Scott (Slides 4-3-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger.
Advertisements

Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Class-level Methods and Inheritance Part 1 Alice.
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.
The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
CSC1401 Animation Creating methods/instructions (class-level)
6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Problem Solving and Algorithm Design
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
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 2009ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
While: Indefinite Loops Sec 8-14 Web Design. Objectives The student will: Understand what an Indefinite Loop is Understand how create an indefinite loop.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Introducing While loops (and random numbers too) Alice.
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.
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 2009ACS-1805 Ron McFadyen1 Point of View An object’s Point of View comprises its position and orientation. Position tells us where the object is in.
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 3 Programming - Putting Together the Pieces.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 8 Recursion.
Fall 2009ACS-1805 Ron McFadyen1 ACS-1805 Introduction to Programming using Alice.
Fall 2007ACS-1805 Ron McFadyen1 Ch 9 Lists In some animations, several objects must perform the same actions Example: A marching band, where the band members.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 4 OO Programming Concepts.
Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
Fall 2007ACS-1805 Ron McFadyen1 Chapter 3 Programming.
Classes, Objects, and World-level Methods
Today’s Agenda 1.Collect Pre-Lab 4 2.Alice Programming Assignment Storyboards 3.Classes 4.Objects 5.Methods 6.Assign pair programming teams and meet upstairs.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Classes, Objects, and World-level Methods Section 47 Web Design.
Simple Program Design Third Edition A Step-by-Step Approach
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Top-Down Design and Modular Development
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.
Getting Started With Alice. Why Learn about Programming computers. Learning to program a computer does not turn you into a nerd We will use Alice which.
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.
Chapter 3 Developing an algorithm. Objectives To introduce methods of analysing a problem and developing a solution To develop simple algorithms using.
Chapter 4: Classes, Objects, and Parameters 4.1 World-Level methods.
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 Where are we? Alice is a “toy” language Fundamentals are exactly like “real”
Chapter 7 Software Engineering Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
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.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Chapter 8 First steps in modularisation. Objectives To introduce modularisation as a means of dividing a problem into subtasks To present hierarchy charts.
Top Down Design Brent M. Dingle Texas A&M University Chapter 4 – Section 1 (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Introduction to OOP in VB.NET using Robots ACSE Conference, Nov 2004 Michael Devoy Monsignor Doyle C.S.S., Cambridge
Fall 2009ACS-1805 Ron McFadyen1 Chapter 2 Program Design & Implementation.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 2 Creating Your First Animation (An Introduction to Programming)
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Further Modularization, Cohesion, and Coupling. Simple Program Design, Fourth Edition Chapter 9 2 Objectives In this chapter you will be able to: Further.
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
Divide and Conquer Methodology
Starting Out with Programming Logic & Design
Chapter 3 Simple Functions
Class-level Methods Alice.
Starting Out with Programming Logic & Design
Top-Down Design & JSP Skill Area Part D
Class-level Methods and Inheritance
Presentation transcript:

Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires: Classes Objects Methods World-level Class-level Parameters Inheritance

Fall 2008ACS-1805 Ron McFadyen2 Classes An OO program is organized around the concept of class. For Alice programming, all classes are pre-defined for us. We choose the classes our program requires from the gallery. We need other skills to build classes If interested, you would want to learn about products such as Maya, Max Studio, … These products are used to construct 3D models Constructing or building classes is outside the scope of this course Two things that distinguish classes: Classes are defined to have properties and methods (including functions)

Fall 2008ACS-1805 Ron McFadyen3 Classes Each class has properties, methods, functions We can customize by creating new properties, methods, functions

Fall 2008ACS-1805 Ron McFadyen4 Objects Showing the relationship amongst classes and objects: Teacher teacher2teacher1 Student student2student1student2

Fall 2008ACS-1805 Ron McFadyen5 Methods Each class/object has a collection of methods that define the things an object from that class can do Move, Turn, Roll, etc We can’t see the code comprising these. (The Alice creators don’t want us to change them and they are referred to as primitive methods We can customize an object by giving it some new methods you are able to edit those OO programmers typically use many many methods where each is defined to some fairly simple thing Methods give us a way of organizing the complexity of our creations Methods become even more useful when they incorporate parameters

Fall 2008ACS-1805 Ron McFadyen6 World-level Methods If we have a complex method, we can break it up into smaller simpler tasks. The main idea is to take a group of related instructions in one method, place them in a separate method, and replace the original lines with a call to the new method The principle we are applying is called abstraction – we are now thinking of the group of instructions as a single instruction

Fall 2008ACS-1805 Ron McFadyen7 Stepwise refinement When creating an algorithm we can design a solution in terms of solutions to smaller problems. This approach is one where we divide and conquer - we break a task down into a number of sub-tasks, each of which is described by an algorithm that is smaller and simpler than that for the entire process. Each sub-task may require further sub-division until we have divided up the problem into elementary pieces, each of which can be tackled in a simple and straightforward way.

Fall 2008ACS-1805 Ron McFadyen8 World-level Methods Original: Code is placed in a new method:

Fall 2008ACS-1805 Ron McFadyen9 World-level Methods Original:Revised: Original is long and complex The revised version is easily understood Note how a method is called

Fall 2008ACS-1805 Ron McFadyen10 Parameters A method is more useful if it can work for different objects A robot walks by turning a leg part backward and then forward We can place these two turns into a method with a parameter – where the parameter is used to specify the part involved

Fall 2008ACS-1805 Ron McFadyen11 Parameters A method with a parameter: Some original code:

Fall 2008ACS-1805 Ron McFadyen12 Parameters Revised: Original: parameters What different kinds of parameters does Alice allow?

Fall 2008ACS-1805 Ron McFadyen13 Consider Project 4, Cleanup Robot We are told to use 3 methods… to make it easier to understand a solution… to make it easier to develop the solution Put Toys Away (storyboard) For each toy: pickup- robot goes and picks up the toy putInCloset- robot takes the toy to the closet Example solution is given in terms of solutions to 2 smaller problems

Fall 2008ACS-1805 Ron McFadyen14 Example pickup- robot goes and picks up the toy Robot turns to face the toy Robot moves toward the toy Robot picks up toy putInCloset- robot takes the toy to the closet Robot turns to face the closet Closet door opens Robot moves into the closet putdown- robot places toy in closet Robot exits from the closet Closet door closes putdown- robot places toy in closet Robot lowers his arms Robot releases the toy Parameters object; distance to move object

Fall 2008ACS-1805 Ron McFadyen15 Example Put toys away pickupputInCloset putdown We can represent the overall organization of our methods (who calls who)