Commit f54cd043 by BellCodeEditor

save project

parent 22354288
Showing with 20 additions and 0 deletions
class Bear:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def up(self):
self.level=self.level+1
self.hp=self.hp-10
self.attack=self.attack-10
YaZi=Bear("鸭子",250,100)
LaoHu=Bear("老虎",250,3.1415926)
ShiZi=Bear("狮子",250,12345)
YaZi.up()
LaoHu.up()
ShiZi.up()
print("鸭子的等级是",YaZi.level,"鸭子的血量是",YaZi.hp,"鸭子的攻击力是",YaZi.attack)
print("老虎的等级是",LaoHu.level,"老虎的血量是",LaoHu.hp,"老虎的攻击力是",LaoHu.attack)
print("狮子的等级是",ShiZi.level,"狮子的血量是",ShiZi.hp,"狮子的攻击力是",ShiZi.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