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
c8d23e97
authored
Feb 27, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
7ad6e31b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
diy.2
diy1.py
diy2.py
diy.2
0 → 100644
View file @
c8d23e97
diy1.py
View file @
c8d23e97
# 英雄角色类
class
Hero
(
object
):
class
Hero
:
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
2
5
0
self
.
hp
=
2
0
0
self
.
attack
=
40
self
.
name
=
name
def
combat
(
self
,
enemy
):
# 攻击
def
combat
(
self
,
enemy
):
enemy
.
hp
-=
self
.
attack
info_1
=
self
.
name
+
'对'
+
enemy
.
name
+
'发起进攻!'
info_2
=
'造成了'
+
str
(
self
.
attack
)
+
'点伤害'
...
...
@@ -15,10 +14,10 @@ class Hero(object):
info
=
info_1
+
info_2
+
info_3
print
(
info
)
else
:
info_3
=
enemy
.
name
+
'已阵亡!'
info_3
=
enemy
.
name
+
'已
经
阵亡!'
info
=
info_1
+
info_2
+
info_3
print
(
info
)
yase
=
Hero
(
"垭瑟"
)
houyi
=
Hero
(
"后羿"
)
yase
=
Hero
(
'亚瑟'
)
houyi
=
Hero
(
'后羿'
)
yase
.
combat
(
houyi
)
\ No newline at end of file
diy2.py
0 → 100644
View file @
c8d23e97
class
Cat
:
def
__init__
(
self
):
self
.
footNum
=
4
# 腿
self
.
eyeNum
=
2
# 眼睛
self
.
head
=
1
# 头
self
.
earsNum
=
2
# 耳朵
self
.
skin
=
"black"
def
run
(
self
):
print
(
"小猫飞快的跑起来"
)
def
skill
(
self
,
prey
):
print
(
'小猫抓住了'
+
prey
)
tom
=
Cat
()
tom
.
skill
(
"老鼠"
)
\ 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