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
b2f32985
authored
Dec 06, 2025
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
ef39df1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
diy.py
diy.py
View file @
b2f32985
class
hero
:
class
Hero
:
def
__init__
(
self
):
def
__init__
(
self
,
name
,
hp
,
gjl
,
s
):
self
.
level
=
1
self
.
name
=
name
self
.
hp
=
300
self
.
level
=
15
self
.
attack
=
2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
self
.
HP
=
hp
self
.
attack
=
gjl
self
.
speed
=
s
print
(
"成功创建英雄"
)
print
(
self
.
name
,
"的血量是: "
,
self
.
HP
,
"
\n
攻击力是: "
,
self
.
attack
)
def
jiasu
(
self
):
self
.
speed
+=
10
print
(
"你的速度增加了10"
)
print
(
"此时英雄是"
,
self
.
speed
)
def
yinshen
(
self
):
print
(
"我隐身起来了,可以偷袭别人"
)
def
shazhupao
(
self
):
print
(
"我使用鲨嘴炮,可以击退别人"
)
jingke
=
Hero
(
"荆轲"
,
500
,
1700
,
30
)
jingke
.
jiasu
()
jingke
.
yinshen
()
jingke
.
shazhupao
()
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