Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_4
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4b940ba8
authored
Apr 09, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
22354288
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
diy2.py
diy2.py
0 → 100644
View file @
4b940ba8
class
Hero
:
#创建类
def
__init__
(
self
,
name
,
hp
,
attack
):
#定义一个方法
self
.
level
=
1
#等级为1
self
.
name
=
name
#英雄的名字
self
.
hp
=
hp
#英雄的血量
self
.
attack
=
attack
#英雄的攻击力
def
uprade
(
self
):
#定义一个升级函数
self
.
level
+=
1
#等级+1
self
.
hp
+=
50
#血量+50
self
.
attack
+=
5
#攻击力+5
houyi
=
Hero
(
'后羿'
,
240
,
23
)
#创建houyi英雄
houyi
.
uprade
()
#houyi升级
print
(
'等级:'
,
houyi
.
level
)
#等级为...
print
(
'血量:'
,
houyi
.
hp
)
#血量为...
print
(
'攻击力:'
,
houyi
.
attack
)
#攻击力为...
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment