Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_test2
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
42f15ad0
authored
Sep 12, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
1a34df6b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
23 deletions
diy2-test.py
diy2-test.py
View file @
42f15ad0
class
Dog
:
# 狗类
# 英雄角色类
def
__init__
(
self
):
class
Hero
(
object
):
self
.
footNum
=
4
# 腿
def
__init__
(
self
,
name
,
a
,
b
,
da
,
db
):
self
.
eyeNum
=
2
# 眼睛
self
.
level
=
1
self
.
head
=
1
# 头
self
.
hp
=
250
self
.
earsNum
=
2
# 耳朵
self
.
attack
=
40
self
.
skin
=
"white"
self
.
name
=
name
self
.
a
=
a
self
.
da
=
da
self
.
b
=
b
self
.
db
=
db
def
combat
(
self
,
en
):
# 攻击
en
.
hp
-=
self
.
attack
print
(
self
.
name
,
"lv:"
+
str
(
self
.
level
),
"at:"
+
str
(
self
.
attack
),
"hp:"
+
str
(
self
.
hp
))
at
=
"普通攻击"
print
(
"-"
*
30
)
print
(
self
.
name
,
"对"
,
en
.
name
,
"使用了"
+
at
,
"
\n
造成了"
+
str
(
self
.
attack
)
+
"点伤害"
)
print
(
"对方还剩"
,
en
.
hp
,
"点血"
)
if
self
.
hp
<
1
:
print
(
"您已阵亡"
)
exit
()
elif
en
.
hp
<
1
:
print
(
"对方已阵亡"
)
exit
()
print
(
"-"
*
30
)
def
run
(
self
):
print
(
"狗狗飞快的跑起来"
)
yase
=
Hero
(
"伏拉夫"
,
"吃火锅"
,
100
,
"吃小孩"
,
105
)
class
Husky
(
Dog
):
# 哈士奇类
houyi
=
Hero
(
"蔡徐坤"
,
"鸡你太美"
,
115
,
"打篮球"
,
75
)
def
__init__
(
self
):
yase
.
combat
(
houyi
)
super
()
.
__init__
()
\ No newline at end of file
self
.
footNum
=
2
# 腿
self
.
eyeNum
=
2
# 眼睛
self
.
head
=
1
# 头
self
.
earsNum
=
2
# 耳朵
self
.
skin
=
"black and white"
coco
=
Husky
()
ococ
=
Dog
()
print
(
coco
.
footNum
,
"
\n
"
,
ococ
.
footNum
)
\ 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