OOP Lecture 06. OOP? Stands for object oriented programming. You’ve been using it all along....
-
Upload
laurence-golden -
Category
Documents
-
view
213 -
download
0
Transcript of OOP Lecture 06. OOP? Stands for object oriented programming. You’ve been using it all along....
![Page 1: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/1.jpg)
OOPLecture 06
![Page 2: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/2.jpg)
OOP?Stands for object oriented programming.You’ve been using it all along.Anything you use the dot ‘.’ on is an object.
![Page 3: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/3.jpg)
Methods and Variables Objects have methods and variables
# Getting a variableself.rect.x # Using a methodmylist.append(54)
![Page 4: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/4.jpg)
ClassesAll objects belong to a classObjects are instances of a classClasses are like a blueprint for objects
![Page 5: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/5.jpg)
Making Classes
class Ball(): def __init__(self, name): self.bounce = False self.name = name
![Page 6: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/6.jpg)
AbstractionGetting all the necessary information for you needs.
![Page 7: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/7.jpg)
Adding Methods
class Ball(): def __init__(self, name): self.bounce = 5 self.name = name def bounce_ball(self): self.bounce = True
![Page 8: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/8.jpg)
Using the ClassesThis means instantiating them, and creating different versions of them
ball1 = Ball("Tennis")ball2 = Ball("Basket")ball3 = Ball("Base") ball1.bounce_ball()print ball1.nameprint ball1.bounceprint ball2.bounce
![Page 9: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/9.jpg)
Calling MethodsMethods are functions on objects.We call them using the ‘.’ operator
![Page 10: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/10.jpg)
Student Class
![Page 11: 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.](https://reader033.fdocuments.in/reader033/viewer/2022051618/56649f515503460f94c74b25/html5/thumbnails/11.jpg)
Inheritance