Advertisement
lump3n

jenya vdolbenko klassi

Jun 3rd, 2023
860
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 1 0
  1. class apple_counter:
  2.     def __init__(self):
  3.         self.apple_num = 10
  4.  
  5.     def sub(self):
  6.         self.apple_num -= 1
  7.  
  8.     def add(self):
  9.         self.apple_num += 1
  10.  
  11.  
  12. eugen_aples = apple_counter()
  13. vanini_aples = apple_counter()
  14. print('Тваи = ', eugen_aples.apple_num, '\n',
  15.       'Маи = ', vanini_aples.apple_num)
  16.  
  17. eugen_aples.sub()
  18. vanini_aples.add()
  19.  
  20. eugen_aples.sub()
  21. vanini_aples.add()
  22.  
  23. eugen_aples.sub()
  24. vanini_aples.add()
  25.  
  26. print('Я спиздил у тебя 3 яблока, селф же обозначает, что это яблоки определенного объекта класса')
  27. print('Тваи = ', eugen_aples.apple_num, '\n',
  28.       'Маи = ', vanini_aples.apple_num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement