Commit 853cacef by BellCodeEditor

save project

parent 15f56494
Showing with 10 additions and 7 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack):
self.level = 1 self.leval = 1
self.name = name self.name = name
self.hp = hp self.hp = hp
self.attack = attack self.attack = attack
...@@ -9,8 +9,11 @@ daqiao = Hero("大乔",320,25) ...@@ -9,8 +9,11 @@ daqiao = Hero("大乔",320,25)
xiaoqiao = Hero("小乔",300,24) xiaoqiao = Hero("小乔",300,24)
libai = Hero("李白",310,25) libai = Hero("李白",310,25)
hanxin = Hero("韩信",340,24) hanxin = Hero("韩信",340,24)
print("孙尚香的血量是:",sunshangxiang.hp)
print("大乔的血量是:",daqiao.hp) def upgrade():
print("小乔的血量是:",xiaoqiao.hp) daqiao.leval = daqiao.leval+1
print("李白的血量是:",libai.hp) daqiao.hp = daqiao.hp+50
print("韩信的血量是:",hanxin.hp) daqiao.attack = daqiao.attack+1
\ No newline at end of file upgrade()
upgrade()
print("大乔的血量为:",daqiao.hp)
\ 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