class Garen:
camp=‘Demacia‘
def __init__(self,nickname,life_value=100,aggresivity=80):
self.nickname=nickname
self.life_value=life_value
self.aggresivity=aggresivity
def attack(self,enemy):
enemy.life_value-=self.aggresivity
class Riven:
camp = ‘Noxus‘
def __init__(self, nickname, life_value=80, aggresivity=100):
self.nickname = nickname
self.life_value = life_value
self.aggresivity = aggresivity
def attack(self, enemy):
enemy.life_value -= self.aggresivity
g1=Garen(‘草丛猥琐男‘)
r1=Riven(‘兔女郎‘)
print(r1.life_value)
g1.attack(r1)
print(r1.life_value)
class Foo:
count=0
def __init__(self,x,y,z):
self.x=x
self.y=y
self.z=z
Foo.count+=1
obj1=Foo(1,1,1)
obj2=Foo(1,2,1)
obj3=Foo(1,2,3)
# print(obj1.count)
# print(Foo.count)