Commit c4966c0c by BellCodeEditor

save project

parent 8e840ee1
Showing with 13 additions and 2 deletions
......@@ -4,10 +4,20 @@ class Hero:
self.hp = hp
self.level = 1
self.attact = attact
def level_up(self):
self.level += 1
self.hp += 50
self.attact += 4
#类方法的局部变量
# color = 'red'
#类方法的属性 局部变量不等于类属性
# self.color = color
yase = Hero("后羿",300,100)
print(yase.hp)
yase = Hero("亚瑟",300,20)
yase.level_up()
print("亚瑟的血量是" + str(yase.hp))
print("亚瑟的攻击是" + str(yase.attact))
print("亚瑟的等级是" + str(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