Files
Douson/Zverushka/ZverushkaWithKlassovoVernim.py
BarsTigerMeowcat cf4a9a0311 1
2020-03-13 14:29:42 +02:00

31 lines
807 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
class Critter(object):
total = 0
@staticmethod
def status():
print("\nВсего зверюшек сейчас", Critter.total)
def __init__(self, name):
print("Появилась на свет новая зверюшка!")
self.name = name
Critter.total += 1
print("Нахожу значение атрибута клсса Critter.total:", end= " ")
print(Critter.total)
print("\nСоздаю зверюшек.")
crit1 = Critter("Звеюшка 1")
crit2 = Critter("Звеюшка 2")
crit3 = Critter("Звеюшка 3")
crit4 = Critter("Звеюшка 4")
Critter.status()
print("\nОбращаюсь к атрибуту класса через объект:", end= " ")
print(crit1.total)
input("\n\nНажмите Ent, чтобы выйти")