Commit a0fa8576 by BellCodeEditor

save project

parent 6d9f43d7
Showing with 15 additions and 4 deletions
class Hero():
def __init__(self):
self.hp=300
def __init__(self,name,hp,attack):
self.name=name
self.hp=hp
self.level=1
self.attack=20
self.attack=attack
def upgrade(self):
self.hp +=50
self.level +=1
self.attack +=10
yase = Hero()
yase = Hero('yase',300,20)
print(yase.hp)
yase.upgrade()
print(yase.hp)
huoyi = Hero('huoyi',240,80)
huoyi.upgrade()
print(huoyi.hp)
\ 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