Commit 01aca6cb by BellCodeEditor

save project

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