Commit 5a1581d3 by BellCodeEditor

save project

parent 22354288
Showing with 23 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 up(self):
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+4
yase=Hero("亚瑟",300,20)
houyi=Hero("后羿",260,23)
lubanqihao=Hero("鲁班七号",400,40)
print("原亚瑟的各项属性为(等级,名字,血量,伤害):",yase.level,yase.name,yase.hp,yase.attack)
print("原后裔的各项属性为(等级,名字,血量,伤害):",houyi.level,houyi.name,houyi.hp,houyi.attack)
print("原鲁班七号的各项属性为(等级,名字,血量,伤害):",lubanqihao.level,lubanqihao.name,lubanqihao.hp,lubanqihao.attack)
yase.up()
houyi.up()
lubanqihao.up()
print("升级后亚瑟的各项属性为(等级,名字,血量,伤害):",yase.level,yase.name,yase.hp,yase.attack)
print("升级后后裔的各项属性为(等级,名字,血量,伤害):",houyi.level,houyi.name,houyi.hp,houyi.attack)
print("升级后鲁班七号的各项属性为(等级,名字,血量,伤害):",lubanqihao.level,lubanqihao.name,lubanqihao.hp,lubanqihao.attack)
\ 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