Commit de4853d6 by BellCodeEditor

save project

parent 22354288
Showing with 20 additions and 0 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def upgrade(self):
self.leveld=self.level+1
self.hp=self.hp+50
self.asttack=self.attack+20
weijunze=Hero("维军则",5,6)
print(weijunze.hp)
chengmingqi=Hero("成名其",7,8)
print(chengmingqi.name)
weijunze.upgrade()
weijunze.upgrade()
print(weijunze.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