Commit 7991eb1f by BellCodeEditor

save project

parent 356f6a53
Showing with 13 additions and 8 deletions
...@@ -4,6 +4,10 @@ class Hero: ...@@ -4,6 +4,10 @@ class Hero:
self.name=kunkun self.name=kunkun
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade(self):
kunkun1.level=self.level+1
kunkun1.hp=self.hp+50
kunkun1.attack=self.attack+10
kunkun1=Hero('kunkun1',300,20) kunkun1=Hero('kunkun1',300,20)
kunkun2=Hero('kunkun2',250,23) kunkun2=Hero('kunkun2',250,23)
kunkun3=Hero('kunkun3',5600,199) kunkun3=Hero('kunkun3',5600,199)
...@@ -12,11 +16,12 @@ print("kunkun2的攻击力:",kunkun2.attack) ...@@ -12,11 +16,12 @@ print("kunkun2的攻击力:",kunkun2.attack)
print("kunkun3的攻击力:",kunkun3.attack) print("kunkun3的攻击力:",kunkun3.attack)
def upgrade():
kunkun1.level=kunkun1.level+1
kunkun1.hp=kunkun1.hp+50
kunkun1.attack=kunkun1.attack+10
upgrade()
upgrade() print("kunkun1的攻击力:",kunkun1.attack)
print("kunkun1的攻击力:",kunkun1.attack)
\ No newline at end of file kunkun2 = Hero("kunkun2",250,23)
kunkun2.upgrade()
print("等级为:",kunkun2.level)
print("生命值为:",kunkun2.hp)
print("攻击力为:",kunkun2.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