Advertisement
programusy

Untitled

Feb 8th, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. class zwierze:
  2. def __init__(self, imie,opis):
  3. self.imie = imie
  4. self.opis = opis
  5.  
  6. @abstractmethod
  7. def display_info(self):
  8. pass
  9.  
  10. class pies(zwierze):
  11. def __init__(self, rasa,waga):
  12. zwierze.__init__(self):
  13. self.rasa = rasa
  14. self.waga = waga
  15.  
  16. def display_info(self):
  17. print(self.rasa)
  18. print(self.waga)
  19.  
  20. class ptak(zwierze):
  21. def __init__(self, kolor, waga):
  22. self.kolor = kolor
  23. self.waga = waga
  24.  
  25. def display_info(self):
  26. print(self.kolor)
  27. print(self.waga)
  28.  
  29. papuga = ptak("zielony", 200)
  30. kanarek = ptak("Kanarek", 10)
  31.  
  32.  
  33. pies1 = pies("Dog",20)
  34. pies2 = pies("Jamnik", 30)
  35.  
  36. pies1.display_info()
  37. pies2.display_info()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement