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
26c191f8
authored
Apr 02, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
71ad00ac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
4 deletions
a,py
a.py
diy1.py
a,py
0 → 100644
View file @
26c191f8
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
\ No newline at end of file
a.py
0 → 100644
View file @
26c191f8
class
Hero
():
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
250
self
.
attack
=
40
self
.
name
=
name
\ No newline at end of file
diy1.py
View file @
26c191f8
...
...
@@ -5,6 +5,7 @@ class Hero(object):
self
.
hp
=
250
self
.
attack
=
40
self
.
name
=
name
def
combat
(
self
,
a
):
# 攻击
a
.
hp
=
a
.
hp
-
self
.
attack
...
...
@@ -16,7 +17,17 @@ class Hero(object):
info2
=
'对'
+
a
.
name
+
'造成'
+
str
(
self
.
attack
)
+
'点伤害'
info
=
info1
+
info2
+
info3
print
(
info
)
yase
=
Hero
(
"垭瑟"
)
class
Player
(
Hero
):
def
__init__
(
self
,
name
,
hp
,
attack
,
level
,
type
):
super
()
.
__init__
(
name
)
self
.
hp
=
hp
self
.
attack
=
attack
self
.
type
=
type
self
.
level
=
level
print
(
'英雄创建成功'
,
'姓名:'
,
self
.
name
,
' '
,
'血量:'
,
self
.
hp
,
' '
,
'攻击:'
,
self
.
attack
,
' '
,
'等级:'
,
self
.
level
,
' '
,
'职业:'
,
type
)
tt
=
Hero
(
"tt"
)
houyi
=
Hero
(
"后羿"
)
yase
.
combat
(
houyi
)
\ No newline at end of file
wjh
=
Player
(
'王锦辉'
,
333
,
333
,
333
,
'刺客'
)
wjh
.
combat
(
tt
)
wjh
.
combat
(
tt
)
wjh
.
combat
(
tt
)
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