Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from abc import ABC, abstractmethod
- class Animal(ABC):
- def __init__(self, name, description):
- self.name = name
- self.description = description
- @abstractmethod
- def display_info(self):
- pass
- class Dog(Animal):
- def __init__(self, name, description, breed, weight):
- Animal.__init__(self, name, description)
- self.breed = breed
- self.weight = weight
- def display_info(self):
- print("Name: ", self.name)
- print("Description: ", self.description)
- print("Breed: ", self.breed)
- print("Weight: ", self.weight)
- class Bird(Animal):
- def __init__(self, name, description, color, weight):
- Animal.__init__(self, name, description)
- self.color = color
- self.weight = weight
- def display_info(self):
- print("Name: ", self.name)
- print("Description: ", self.description)
- print("Color: ", self.color)
- print("Weight: ", self.weight)
- dog1 = Dog("Ass", "Doberman", "Doberman", 30)
- dog2 = Dog("Asik", "Jamnik", "Terrier", 15)
- bird1 = Bird("Papuga", "Parrot", "Green", 1)
- bird2 = Bird("Kanarek", "Canary", "Yellow", 0.5)
- dog1.display_info()
- print()
- dog2.display_info()
- print()
- bird1.display_info()
- print()
- bird2.display_info()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement