Commit adbda568 by BellCodeEditor

save project

parent fd9075f0
Showing with 10 additions and 2 deletions
...@@ -3,7 +3,15 @@ class Hero: ...@@ -3,7 +3,15 @@ class Hero:
self.hp = hp self.hp = hp
self.name = name self.name = name
self.attack = attack self.attack = attack
self.lv = 1
xiaoming = Hero(10,"小明",2) xiaoming = Hero(10,"小明",2)
xiaohong = Hero(25,"小红",10) xiaohong = Hero(25,"小红",10)
print(xiaoming.name,"击败了",xiaohong.name,"的等级增加一级")
def upup():
xiaoming.lv = xiaoming.lv+1
xiaoming.hp = xiaoming.hp+1
xiaoming.attack = xiaoming.attack+1
print('现在',xiaoming.name,"的等级为",xiaoming.lv,"血量为",xiaoming.hp,"攻击力为",xiaoming.attack)
print(xiaoming.name,"的攻击力为",xiaoming.attack) print(xiaoming.name,"的攻击力为",xiaoming.attack)
print(xiaohong.name,"的攻击力为",xiaohong.attack) print(xiaohong.name,"的攻击力为",xiaohong.attack)
\ No newline at end of file upup()
\ 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