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
3ed9ff42
authored
Sep 24, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
9a581ef4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
demo.py
demo1.py
diy1.py
demo.py
0 → 100644
View file @
3ed9ff42
class
Dog
:
def
__init__
(
self
,
color
):
self
.
tui
=
4
# 腿 这个实例的属性
self
.
er
=
2
# 耳
self
.
yan
=
2
# 眼
self
.
color
=
color
huang
=
Dog
(
"黑色"
)
print
(
huang
.
color
,
huang
.
tui
)
demo1.py
0 → 100644
View file @
3ed9ff42
class
Dog
:
def
__init__
(
self
,
color
,
price
):
self
.
tui
=
4
# 腿
self
.
er
=
2
# 耳
self
.
yan
=
2
# 眼
self
.
color
=
color
self
.
price
=
price
dog1
=
Dog
(
"黑色"
,
100.0
)
print
(
dog1
.
color
,
dog1
.
price
)
diy1.py
View file @
3ed9ff42
...
...
@@ -6,9 +6,13 @@ class Hero(object):
self
.
attack
=
40
self
.
name
=
name
def
combat
():
# 攻击
???
def
combat
(
self
,
beigongji
):
# 攻击
beigongji
.
hp
=
beigongji
.
hp
-
self
.
attack
info1
=
?
#攻击与被攻击者
info2
=
?
# 攻击力造成的伤害!
info3
=
?
# 剩余血量
info
=
info1
+
info2
+
info3
# 将上面3段字符串拼接成一段语句输出!
print
(
info1
)
yase
=
Hero
(
"垭瑟"
)
houyi
=
Hero
(
"后羿"
)
yase
.
combat
(
houyi
)
\ 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