Commit e08f4a1f by BellCodeEditor

save project

parent 9f18226f
Showing with 11 additions and 3 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack):
self.level=1 self.level=3
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
yase=Hero('牙色',10,1000)
houyi=Hero('侯毅',1000,5) def upgrade(self):
self.level+=1
self.hp+=50
self.attack+=4
yase=Hero('牙色',1000,5)
yase.upgrade()
houyi=Hero('侯毅',10,10005)
print('牙色的血量为:',yase.hp) print('牙色的血量为:',yase.hp)
houyi.upgrade()
print('侯毅的血量为:',houyi.hp) print('侯毅的血量为:',houyi.hp)
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