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
76a47570
authored
Jun 21, 2025
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
0f0fa545
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
19 deletions
diy2-test.py
diy2-test.py
View file @
76a47570
class
Dog
:
# 狗类
class
Hero
:
def
__init__
(
self
):
def
_init_
(
self
,
hp
,
attack
,
name
):
self
.
footNum
=
4
# 腿
self
.
leve1
=
1
self
.
eyeNum
=
2
# 眼睛
self
.
hp
=
hp
self
.
head
=
1
# 头
self
.
attack
=
attack
self
.
earsNum
=
2
# 耳朵
self
.
name
=
name
self
.
skin
=
"white"
#def upgrade(self):
# self.leve1=self.leve1+1
def
run
(
self
):
# self.hp=self.hp+50
print
(
"狗狗飞快的跑起来"
)
# self.attack=attack+4
def
combat
(
self
,
enemy
):
if
enemy
.
hp
>
0
class
Husky
(
Dog
):
# 哈士奇类
enemy
.
hp
-=
self
.
attack
def
__init__
(
self
):
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起进攻,"
??
info2
=
"造成"
+
str
(
self
.
attack
)
+
"点伤害,"
info3
=
enemy
.
name
+
"剩余血量"
+
str
(
enemy
.
hp
)
+
"点"
coco
=
Husky
()
info
=
info1
+
info2
+
info3
print
(
coco
.
skin
)
print
(
into
)
\ No newline at end of file
else
:
info3
=
enemy
.
name
+
"阵亡,游戏结束"
info
=
info1
+
info2
+
info3
print
(
into
)
exit
()
class
player
(
hero
):
def
_init_
(
name
)
self
.
hp
=
200
self
.
attack
=
50
self
.
hero_type
=
hero_type
houyi
=
player
(
"后羿"
,
"射手"
)
yase
=
hero
(
"亚瑟"
)
houyi
=
player
(
"后羿"
)
houyi
。
combat
(
yase
)
\ 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