Commit 4c102aaf by BellCodeEditor

save project

parent f47689a4
Showing with 16 additions and 0 deletions
#定义英雄类
class Hero:
#self实例化的形参
def __init__(self):
#等级
self.level = 1
#血量
self.hp = 300
#攻击力
self.attack = 20
#创建实例化对象 亚瑟
yase = Hero()
#输出亚瑟的血量、等级、攻击力
print("亚瑟的血量为:",yase.hp)
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