Commit efecca72 by BellCodeEditor

save project

parent 615e807d
Showing with 65 additions and 8 deletions
# 英雄角色类
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
def combat(self,enemy):
enemy.hp=enemy.hp-self.attack
show1=str(self.name)+"对"+str(enemy.name)"造成"+str(self.attack)+"点伤害"+str(enemy.name)"还剩下"str(enemy.hp)'点生命'
print(show)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
......@@ -4,14 +4,53 @@ class hero :
self.name = name
self.hp = hp
self.attack = attack
def upgrade(self):
self.level=self.level+1
self.hp =self.hp+50
self.attack=self.attack+4
yase = hero('yase',300,20)
yase.upgrade()
print(yase.level)
'''yase = hero('yase',300,20)
def
yase = hero('yase',300,20)
houyi= hero('houyi',250,23)
''' def upgrade(self):
self.level=self.level+1
self.hp =self.hp+50
self.attack=self.attack+4
yase = hero('yase',300,20)'''
'''yase = hero('yase',300,20)
houyi= hero('houyi',250,23)
print(yase.name)
def upgrade():
......
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