Commit 5ebeb884 by BellCodeEditor

save project

parent f1b291e9
Showing with 16 additions and 7 deletions
class Hero: class Hero:
def __init__(self): def __init__(self,name,hp,attack):
self.level = 1 self.level = 1
self.hp = 3000 self.name = name
self.attack = 120 self.hp = hp
self.attack = attack
yase = Hero() def upgrade(self):
print("亚瑟的血量是:"yase.hp) self.level = self.level + 1
print("亚瑟的攻击力是:"yase.attack) self.hp = self.hp + 50
\ No newline at end of file self.attack = self.attack + 4
yase = Hero("亚瑟",200,15)
yase.upgrade()
yase.upgrade()
print("亚瑟升级两次后的血量是:",yase.hp)
print("亚瑟升级两次后的等级是:",yase.level)
print("亚瑟升级两次后的攻击力是:",yase.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