Commit 01aca6cb by BellCodeEditor

save project

parent 19ebae31
Showing with 18 additions and 15 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack):
self.level= 1 self.level=1
self.name= name self.name=name
self.hp= hp self.hp=hp
self.attack= attack self.attack=attack
yase = Hero('yese',300,20)
yase1 = Hero('blsy',290,50) def upgrade(self):
yase2 = Hero('k',450,30) self.leve=self.level+1
yase3 = Hero('bq',420,40) self.hp=self.hp+50
yase4 = Hero('dm',340,35) self.attack=self.attack+4
print(yase.name,yase.hp,yase.attack)
print(yase1.name,yase1.hp,yase1.attack) yase=Hero('亚瑟',300,20)
print(yase2.name,yase2.hp,yase2.attack)
print(yase3.name,yase3.hp,yase3.attack) yase.upgrade()
print(yase4.name,yase4.hp,yase4.attack)
\ No newline at end of file print('等级',yase.level)
print('血量',yase.hp)
print('攻击力',yase.attack)
\ No newline at end of file
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