Commit daf6be61 by BellCodeEditor

save project

parent 678c1820
Showing with 48 additions and 6 deletions
...@@ -4,14 +4,17 @@ class Hero: ...@@ -4,14 +4,17 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade(self):
self.level+=1
self.hp+=50
self.attack+=4
yase=Hero('垭瑟',300,20) yase=Hero('垭瑟',300,20)
houyi=Hero('后羿',250,23) houyi=Hero('后羿',250,23)
print(yase.attack) print(yase.attack)
#print(houyi.hp) #print(houyi.hp)
def upgrade(): yase.upgrade()
yase.level+=1
yase.hp+=50
yase.attack+=4
upgrade()
upgrade()
print(yase.attack) print(yase.attack)
print(houyi.attack)
#print(houyi.hp)
houyi.upgrade()
print(houyi.attack)
\ No newline at end of file
class JinZhan:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def upgrade(self):
self.level+=1
self.hp+=500
self.attack+=4
class YuanCheng:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def upgrade(self):
self.level+=1
self.hp+=50
self.attack+=40
yase=JinZhan('垭瑟',300,20)
houyi=YuanCheng('后羿',250,23)
c=JinZhan('c',400,10)
d=YuanCheng('d',1100,30)
print('yasehp:'+str(yase.hp))
print('houyihp:'+str(houyi.hp))
print('chp:'+str(c.hp))
print('dhp:'+str(d.hp))
yase.upgrade()
houyi.upgrade()
c.upgrade()
d.upgrade()
print('yasehp:'+str(yase.hp))
print('houyihp:'+str(houyi.hp))
print('chp:'+str(c.hp))
print('dhp:'+str(d.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