|
@@ -0,0 +1,52 @@
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class Cat:
|
|
|
|
+
|
|
|
|
+ breed = 'pers'
|
|
|
|
+
|
|
|
|
+ def hello():
|
|
|
|
+ print("hello")
|
|
|
|
+
|
|
|
|
+ def show_breed(instance):
|
|
|
|
+ print(f'my breed is {instance.breed}')
|
|
|
|
+ print(instance)
|
|
|
|
+
|
|
|
|
+ def show_name(instance):
|
|
|
|
+ if hasattr(instance, 'name'):
|
|
|
|
+ print(f'my name is {instance.name}')
|
|
|
|
+ else:
|
|
|
|
+ print('nothing')
|
|
|
|
+
|
|
|
|
+ def set_value(koshka, value, age=0):
|
|
|
|
+ koshka.name = value
|
|
|
|
+ koshka.age = age
|
|
|
|
+
|
|
|
|
+ def new_method(self):
|
|
|
|
+ pass
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def main():
|
|
|
|
+ # cat = Cat()
|
|
|
|
+ # cat.show_breed()
|
|
|
|
+
|
|
|
|
+ # tom = Cat()
|
|
|
|
+ # print(isinstance(tom, Cat))
|
|
|
|
+
|
|
|
|
+ # tom.show_name()
|
|
|
|
+ # tom.set_value('Tom')
|
|
|
|
+ # tom.show_name()
|
|
|
|
+
|
|
|
|
+ leo = SoccerPlayer('Leo', 'Messi')
|
|
|
|
+ print(leo.__dict__)
|
|
|
|
+ assert isinstance(leo, SoccerPlayer)
|
|
|
|
+
|
|
|
|
+ assert leo.__dict__ == {'name': 'Leo', 'surname': 'Messi', 'goals': 0, 'assists': 0}
|
|
|
|
+ # leo.score(700)
|
|
|
|
+ # assert leo.goals == 700
|
|
|
|
+ # leo.make_assist(500)
|
|
|
|
+ # assert leo.assists == 500
|
|
|
|
+
|
|
|
|
+ # leo.statistics()
|
|
|
|
+
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
+ main()
|