OOP Lecture 06. OOP? Stands for object oriented programming. You’ve been using it all along. Anything you use the dot ‘.’ on is an object.

Slides:



Advertisements
Similar presentations
The Important Thing About By. The Important Thing About ******** The important thing about ***** is *****. It is true s/he can *****, *****, and *****.
Advertisements

Object-Oriented Programming
Object-Oriented Programming Python. OO Paradigm - Review Three Characteristics of OO Languages –Inheritance It isn’t necessary to build every class from.
Python Mini-Course University of Oklahoma Department of Psychology Lesson 26 Classes and Objects 6/16/09 Python Mini-Course: Lesson 26 1.
C++ Classes & Data Abstraction
Object Oriented Programming in Java. Object Oriented Programming Concepts in Java Object oriented Programming is a paradigm or organizing principle for.
OBJECT ORIENTED PROGRAMMING (OOP) IN PYTHON David Moodie.
Overview1 History of Programming Languages n Machine languages n Assembly languages n High-level languages – Procedure-oriented – Object-oriented/Event-driven.
Object Oriented Design and Classes
INFO 206 Lab Exercise 1 Introduction to Classes and Objects 1/18/2012i206 Lab 1 - Exercise1.
Object Oriented Design and Classes. What is a class? Programming mechanism to support OOD Data and the methods that operate on that data – collectively.
Generalized De Morgan’s Theorem Lecture L5.4 Section 5.1.
REFERENCES: CHAPTER 8 Object-Oriented Programming (OOP) in Python.
CS61A Lecture 14 Object-Oriented Programming Jom Magrotker UC Berkeley EECS July 11, 2012.
Guide to Programming with Python Chapter Nine Working with/Creating Modules.
Python Crash Course Classes 3 rd year Bachelors V1.0 dd Hour 7.
Inheritance. Inhertance Inheritance is used to indicate that one class will get most or all of its features from a parent class. class Dog(Pet): Make.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
1. MORE TRIG (AND BASIC VECTORS) 2. INHERITANCE (CHAPTER 9) Lecture 10 (Last one!)
By: Chris Harvey Python Classes. Namespaces A mapping from names to objects Different namespaces have different mappings Namespaces have varying lifetimes.
Classes 1 COMPSCI 105 S Principles of Computer Science.
Chapter 12 Object Oriented Design.  Complements top-down design  Data-centered view of design  Reliable  Cost-effective.
CLASSES Python Workshop. Introduction  Compared with other programming languages, Python’s class mechanism adds classes with a minimum of new syntax.
PYTHON OBJECTS & CLASSES. What is an object? The abstract idea of anything What is in an object: Attributes Characteristics Represented by internal variables.
11/4/2015BCHB Edwards Advanced Python Concepts: Object Oriented Programming BCHB Lecture 17.
Guide to Programming with Python Chapter Eight (Part I) Object Oriented Programming; Classes, constructors, attributes, and methods.
1 Class 1 Lecture Topic Concepts, Definitions and Examples.
Object Oriented Programming In Python
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
11/9/2015BCHB Edwards Advanced Python Concepts: OOP & Inheritance BCHB Lecture 18.
PyGame - Unit 4 PyGame Unit – Object Oriented Programming OOP.
Dr. Philip Cannata 1 Python Overview. Dr. Philip Cannata 2 “Bad program” developed during class # The following python statement has python variables.
Object-Oriented Programming (OOP) in Python References: Chapter 8.
CMSC201 Computer Science I for Majors Lecture 25 – Classes
Objects as a programming concept
Adapted from slides by Marty Stepp and Stuart Reges
Object-Oriented Programming (OOP) in Python
Interface, Subclass, and Abstract Class Review
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Advanced Python Concepts: Object Oriented Programming
Lecture VI Objects The OOP Concept Defining Classes Methods
Object Oriented Concepts
Advanced Python Concepts: OOP & Inheritance
Engineering Computing
Introduction to Object-oriented Program Design
Adapted from slides by Marty Stepp and Stuart Reges
Object-oriented Design in Processing
Teach A-Level Computer Science: Object-Oriented Programming in Python
Python Classes Python has Classes, Methods, Overloaded operators, as well as Inheritance. Its somewhat 'loose' in the since it does not have true encapsulation,
Advanced Python Concepts: OOP & Inheritance
Using the coords function (Coordinates)
Solution Solution Checking Solutions of Inequalities
Advanced Python Concepts: Object Oriented Programming
What is 5 X 7? RIGHT! OOPS Move Along.
Object-oriented Design in Processing
Object Oriented Programming (OOP) LAB # 9
Fundamentals of Programming I Commonly Used Methods More Modeling
C++ Programming ㅎㅎ String OOP Class Constructor & Destructor.
Ball meets Paddle.
Advanced Python Concepts: OOP & Inheritance
Advanced Python Concepts: Object Oriented Programming
CSE 231 Lab 11.
Object-oriented Design in Processing
polymorphism Inheritance Base class Derived class
Understanding OOPs.
Variables and Equations
Ch. 1 Vocabulary Alice.
Object-oriented Design in Processing
Presentation transcript:

OOP Lecture 06

OOP? Stands for object oriented programming. You’ve been using it all along. Anything you use the dot ‘.’ on is an object.

Methods and Variables Objects have methods and variables # Getting a variable self.rect.x # Using a method mylist.append(54) # Getting a variable self.rect.x # Using a method mylist.append(54)

Classes All objects belong to a class Objects are instances of a class Classes are like a blueprint for objects

Making Classes class Ball(): def __init__(self, name): self.bounce = False self.name = name class Ball(): def __init__(self, name): self.bounce = False self.name = name

Abstraction Getting all the necessary information for you needs.

Adding Methods class Ball(): def __init__(self, name): self.bounce = 5 self.name = name def bounce_ball(self): self.bounce = True class Ball(): def __init__(self, name): self.bounce = 5 self.name = name def bounce_ball(self): self.bounce = True

Using the Classes This means instantiating them, and creating different versions of them ball1 = Ball("Tennis") ball2 = Ball("Basket") ball3 = Ball("Base") ball1.bounce_ball() print ball1.name print ball1.bounce print ball2.bounce ball1 = Ball("Tennis") ball2 = Ball("Basket") ball3 = Ball("Base") ball1.bounce_ball() print ball1.name print ball1.bounce print ball2.bounce

Calling Methods Methods are functions on objects. We call them using the ‘.’ operator

Student Class

Inheritance