-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoop.py
More file actions
27 lines (17 loc) · 485 Bytes
/
oop.py
File metadata and controls
27 lines (17 loc) · 485 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
# -*- coding: utf-8 -*-
class Animal:
# Constructor
def __init__(self, p1, p2):
self.param1 = p1
self.param2 = p2
animal = Animal("str1", 10)
print("Values: {}, {}".format(animal.param1, animal.param2))
# Herança.
class Dog(Animal):
def __init__(self, p1, p2):
Animal.__init__(self, p1, p2)
def print_values(self):
print("Dog: {}, {}".format(self.param1, self.param2))
dog = Dog("a", "b")
dog.print_values()