Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_1
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
5fd1d5b4
authored
Jul 16, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
f47689a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
diy.py
diy.py
View file @
5fd1d5b4
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
1
#等级
self
.
name
=
name
self
.
hp
=
hp
#血量
self
.
attack
=
attack
#攻击力
#属性升级
def
upgrade
(
self
):
self
.
level
+=
1
self
.
hp
+=
50
self
.
attack
+=
5
#实例化对象
houyi
=
Hero
(
'后羿'
,
240
,
25
)
yase
=
Hero
(
'亚瑟'
,
400
,
18
)
zhaoyun
=
Hero
(
'赵云'
,
300
,
22
)
machao
=
Hero
(
'马超'
,
300
,
24
)
huangzhong
=
Hero
(
'黄忠'
,
260
,
20
)
daji
=
Hero
(
'妲己'
,
200
,
70
)
houyi
.
upgrade
()
print
(
'后羿的属性值是:'
,
houyi
.
level
,
houyi
.
hp
,
houyi
.
attack
)
print
(
'亚瑟的属性值是:'
,
yase
.
level
,
yase
.
hp
,
yase
.
attack
)
zhaoyun
.
upgrade
()
print
(
'赵云的属性值是:'
,
zhaoyun
.
level
,
zhaoyun
.
hp
,
zhaoyun
.
attack
)
print
(
'马超的属性值是:'
,
machao
.
level
,
machao
.
hp
,
machao
.
attack
)
huangzhong
.
upgrade
()
print
(
'黄忠的属性值是:'
,
huangzhong
.
level
,
huangzhong
.
hp
,
huangzhong
.
attack
)
print
(
'妲己的属性值是:'
,
daji
.
level
,
daji
.
hp
,
daji
.
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