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
deb8d502
authored
Mar 23, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
1cf9f5c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
diy2-test.py
diy2-test.py
View file @
deb8d502
class
Dog
:
# 狗类
# 创建玩家类Player放入参数Hero
def
__init__
(
self
):
self
.
footNum
=
4
# 腿
self
.
eyeNum
=
2
# 眼睛
self
.
head
=
1
# 头
self
.
earsNum
=
2
# 耳朵
self
.
skin
=
"white"
def
run
(
self
):
# 创建__init__()函数方法并放入参数self,name,hero_type
print
(
"狗狗飞快的跑起来"
)
# 使用super()函数继承父类方法__init__()并放入参数name
class
Husky
(
Dog
):
# 哈士奇类
# 重写英雄血量200
def
__init__
(
self
):
??
coco
=
Husky
()
# 重写英雄攻击力50
print
(
coco
.
skin
)
\ No newline at end of file
# 重写英雄类型
# 角色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