Commit 9fe1ea8f by BellCodeEditor

save project

parent d0099acb
Showing with 24 additions and 10 deletions
...@@ -4,15 +4,30 @@ class Hero: ...@@ -4,15 +4,30 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrand(self):
self.level=self.level+1
self.hp=self.hp+1
self.attack=self.attack+1
yase=Hero('亚瑟',300,20) yase=Hero('亚瑟',300,20)
hy=Hero('后羿',250,23) hy=Hero('后羿',250,23)
k=Hero('凯',5600,200) k=Hero('凯',5600,200)
print(yase.attack) # print(yase.attack)
print(hy.attack) # print(hy.attack)
print(k.name) print(k.level)
def upgrand(): k.upgrand()
yase.level=yase.level+1 print(k.level)
yase.hp=yase.hp+1
yase.attack=yase.attack+1
upgrand()
print(yase.level)
\ 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