Commit dc3d73ed by BellCodeEditor

auto save

parent f42bb96f
Showing with 35 additions and 0 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level = 1
self.name = name
self.hp = hp
self.attack = attack
def upgrade(self):
yase.hp = yase.hp+100
yase.level = yase.level+1
yase.attack = yase.attack+50
libai = Hero("李白",200,30)
yase = Hero("亚瑟",250,20)
yase.upgrade()
libai.upgrade()
print(libai.hp)
# print(yase.hp)
\ No newline at end of file
#定义类
class Hero():
def __init__(self,name,hp,attack):
self.level = 1
self.name = name
self.hp = hp
self.attack = attack
libai = Hero("李白",200,30)
yase = Hero("亚瑟",250,20)
def upgrade():
yase.hp = yase.hp+100
yase.level = yase.level+1
yase.attack = yase.attack+10
upgrade()
print(libai.hp)
print(yase.level)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment