Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_test1
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
450a3696
authored
Mar 23, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
1204277e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
diy-test1.py
diy-test1.py
View file @
450a3696
...
...
@@ -19,11 +19,27 @@ class Hero:
info
=
info1
+
info2
+
info3
print
(
info
)
exit
()
class
Player
(
Hero
):
def__init__
(
self
,
name
):
super
()
.
__init__
(
name
)
self
.
hp
=
200
self
.
attack
=
50
houyi
=
Player
(
"后羿"
)
# 创建玩家类Player放入参数Hero
houyi
=
Player
(
"后羿"
,
"射手"
)
yase
=
Hero
(
"亚瑟"
)
print
(
houyi
.
hp
)
print
(
houyi
.
attack
)
# 创建__init__()函数方法并放入参数self,name,hero_type
# 使用super()函数继承父类方法__init__()并放入参数name
# 重写英雄血量200
# 重写英雄攻击力50
# 重写英雄类型
# 角色xx创建成功
# 当前等级, 血量,攻击力分别为 1,200,50
# 创建对象houyi参数"后羿", "射手"
# 创建对象yase
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