Commit 493a67b1 by BellCodeEditor

auto save

parent d4ac94c7
Showing with 19 additions and 19 deletions
class hero:
def __init__(self,hp,attack):
self.level=1
#self.name=name
self.hp=hp
self.attack=attack
#yase=hero(200,300)
#yase.hp=250 #变量里的数值取决于最后一次赋值内容
def upgrade(self):
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+20
daji=hero(300,200)
for i in range(1,10):
daji.level=i
daji.attack=daji.attack+100
daji.hp=daji.hp+50
print(daji.hp)
\ No newline at end of file
yase=hero(200,300)
yase.upgrade()
print(yase.attack)
......@@ -3,13 +3,11 @@ class hero:
self.level=1
self.hp=hp
self.hk=hk
ye=hero(100,12)
ye.hp=300
print(ye.hp)
def upgrade(self):
self.level=self.level+1
self.hp=self.hp+50
self.hk=self.hk+30
upgrade(ye)
print(ye.hp)
\ No newline at end of file
def upgrade(self):
self.level=self.level+1
self.hp=self.hp+50
self.hk=self.hk+30
ye=hero(100,20)
upgrade(ye)
print(ye.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