Commit c2dcc87d by BellCodeEditor

save project

parent 6377e47c
Showing with 20 additions and 9 deletions
...@@ -4,11 +4,22 @@ class hero: ...@@ -4,11 +4,22 @@ class hero:
self.hp = hp self.hp = hp
self.level = level self.level = level
self.name = name self.name = name
yase = hero("yase",300,20,1)
def uplevel(): def uplevel(self):
yase.level = yase.level + 1 self.level = self.level + 1
yase.hp = yase.hp + 50 self.hp = self.hp + 50
yase.attack = yase.attack + 4 self.attack = self.attack + 4
uplevel()
uplevel() def printdata(self):
print("亚瑟的血量为:",yase.hp) print(self.name,"level=",self.level)
\ No newline at end of file print(self.name,"attack=",self.attack)
print(self.name,"hp=",self.hp)
yase = hero("yase",300,21,1)
houyi = hero("houyi",240,24,1)
yase.uplevel()
houyi.uplevel()
yase.printdata()
houyi.printdata()
\ 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