Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_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
99cac010
authored
Apr 18, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
fa91dcc7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
diy1.py
diy1.py
View file @
99cac010
class
hero
:
def
__init__
(
self
,
name
,
level
,
hp
,
attack
):
self
.
level
=
level
self
.
hp
=
hp
self
.
attack
=
attack
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
250
self
.
attack
=
40
self
.
name
=
name
LuBan
=
hero
(
'鲁班'
,
1
,
2500
,
230
)
HouYi
=
hero
(
'后羿'
,
1
,
3000
,
180
)
def
combat
(
self
):
print
(
LuBan
.
name
)
print
(
LuBan
.
level
)
print
(
LuBan
.
hp
)
print
(
LuBan
.
attack
)
print
(
LuBan
.
name
)
print
(
LuBan
.
level
)
print
(
LuBan
.
hp
)
print
(
LuBan
.
attack
)
def
combat
(
self
,
a
):
a
.
hp
-=
self
.
attack
x0
=
a
.
name
+
'已阵亡,Game over'
x1
=
self
.
name
+
'使用了攻击技能,'
x2
=
'使'
+
a
.
name
+
'受到了'
+
str
(
self
.
attack
)
+
'点伤害,'
x3
=
a
.
name
+
'的血量还剩'
+
str
(
a
.
hp
)
+
'点'
if
a
.
hp
>
0
:
y1
=
x1
+
x2
+
x3
print
(
y1
)
else
:
y2
=
x1
+
x2
+
x3
print
(
y2
)
LuBan
=
hero
(
'鲁班'
)
HouYi
=
hero
(
'后羿'
)
HouYi
.
combat
(
LuBan
)
\ 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