Commit fc1d1b6c by BellCodeEditor

auto save

parent 6c0b0cc3
Showing with 29 additions and 9 deletions
class Hero():
def __init__(self):
self.level = 1
self.hp = 300
self.attack = 20
yase = Hero()
print(yase.hp)
\ No newline at end of file
class Hero:
#默认函数
def __init__(self,level,hp,attack):
self.level = level
self.hp=hp
self.attack=attack
def up(self):
self.level = self.level+1
self.hp =self.hp+40
self.attack =self.attack + 20
yase = Hero(1,300,20)
libai = Hero(2,200,50)
dufu = Hero(3,100,100)
yase.up()
libai.up()
#定义函数
#p 形式参数
def a(p):
p = p + 1
return p
#调用函数 函数名加括号
#1 实际参数
z = a(1)
print(z)
\ 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