Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_3
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
df53ee8b
authored
Oct 06, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
a7a79e98
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
13 deletions
diy2.py
diy2.py
View file @
df53ee8b
class
Dog
:
class
Hero
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
footNum
=
4
self
.
lv
=
0
self
.
eyeNum
=
2
self
.
hp
=
0
self
.
head
=
1
self
.
att
=
0
self
.
earsNum
=
2
self
.
name
=
"默认英雄"
self
.
skin
=
"white"
self
.
maxhp
=
self
.
hp
def
run
(
self
):
print
(
"创建了一个默认英雄,他的血量是"
,
self
.
hp
)
print
(
"狗狗飞快的跑起来"
)
def
gongji
(
self
,
e
):
e
.
hp
-=
self
.
att
print
(
self
.
name
+
"攻击"
+
e
.
name
+
"造成"
+
str
(
self
.
att
)
+
"点伤害,"
+
e
.
name
+
"剩"
+
str
(
e
.
hp
)
+
"点血。"
)
class
Husky
(
Dog
):
def
cure
(
self
):
def
__init__
(
self
):
self
.
hp
+=
50
if
self
.
hp
>
self
.
maxhp
:
self
.
hp
=
self
.
maxhp
print
(
self
.
name
,
"治疗到"
,
self
.
hp
)
class
Player
(
Hero
):
def
__init__
(
self
,
h
,
a
,
n
):
super
()
.
__init__
()
super
()
.
__init__
()
self
.
skin
=
"white+balck"
self
.
hp
=
h
self
.
att
=
a
self
.
name
=
n
self
.
maxhp
=
self
.
hp
print
(
"恭喜你获得英雄:"
+
self
.
name
+
"他的血量是:"
)
p1
=
Player
(
500
,
90
,
"张飞"
)
p2
=
Player
(
300
,
60
,
"岩石"
)
p
et
=
Husky
(
)
p
1
.
gongji
(
p2
)
p
rint
(
pet
.
skin
)
p
2
.
cure
()
\ 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