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
556629f5
authored
Jan 18, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
602b46c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
diy.py
diy.py
View file @
556629f5
class
Hero
:
def
__init__
(
self
,
hp
,
Gj
):
def
__init__
(
self
,
name
,
hp
,
Gj
):
self
.
hp
=
hp
self
.
Gj
=
Gj
self
.
dj
=
1
#houyi=Hero(50,30)
#print(houyi.Gj)
self
.
name
=
name
def
shj
(
self
):
self
.
dj
=
self
.
dj
+
1
self
.
Gj
=
self
.
Gj
+
5
self
.
hp
=
self
.
hp
+
10
yase
=
Hero
(
100
,
20
)
def
j
(
self
,
enemy
):
enemy
.
hp
=
enemy
.
hp
-
self
.
Gj
q1
=
self
.
name
+
'对'
+
enemy
.
name
+
'发起攻击'
q2
=
'造成了'
+
str
(
self
.
Gj
)
+
'伤害'
q3
=
enemy
.
name
+
'还剩'
+
str
(
enemy
.
hp
)
q
=
q1
+
q2
+
q3
print
(
q
)
class
Player
(
Hero
):
pass
yase
=
Hero
(
'亚瑟'
,
100
,
20
)
yase
.
shj
()
print
(
'亚瑟生命值为:'
,
yase
.
hp
)
print
(
'亚瑟攻击值为:'
,
yase
.
Gj
)
print
(
'亚瑟等级为:'
,
yase
.
dj
)
houyi
=
Hero
(
50
,
40
)
houyi
=
Player
(
'后羿'
,
50
,
40
)
houyi
.
shj
()
print
(
'后羿生命值为:'
,
houyi
.
hp
)
print
(
'后羿攻击值为:'
,
houyi
.
Gj
)
print
(
'后羿等级是:'
,
houyi
.
dj
)
\ No newline at end of file
print
(
yase
.
name
)
print
(
houyi
.
name
)
yase
.
j
(
houyi
)
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