Commit c4b043bb by BellCodeEditor

save project

parent 25d15a72
Showing with 7 additions and 6 deletions
......@@ -4,12 +4,14 @@ class Hero:#定义一个类名
self.attack=attack#攻击力
self.fangyu=fangyu#防御力
self.name=name
def sj(self):
self.hp+=200
self.attack+=100
self.fangyu+=54
zhaoyun=Hero(350,785,232,"赵云")#类的实例
sunshangxiang=Hero(365,684,324,"孙尚香")
zhaoyun.sj()
sunshangxiang.sj()
sunshangxiang.sj()
print(zhaoyun.hp,zhaoyun.name)#打印赵云的攻击力
def sj():
sunshangxiang.hp+=200
sunshangxiang.attack+=100
sunshangxiang.fangyu+=54
sj()
print(sunshangxiang.hp,sunshangxiang.name)
\ 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