Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_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
c4b043bb
authored
Nov 13, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
25d15a72
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
diy.py
diy.py
View file @
c4b043bb
...
...
@@ -4,12 +4,14 @@ class Hero:#定义一个类名
self
.
attack
=
attack
#攻击力
self
.
fangyu
=
fangyu
#防御力
self
.
name
=
name
def
sj
(
self
):
self
.
hp
+=
200
self
.
attack
+=
100
self
.
fangyu
+=
54
zhaoyun
=
Hero
(
350
,
785
,
232
,
"赵云"
)
#类的实例
sunshangxiang
=
Hero
(
365
,
684
,
324
,
"孙尚香"
)
zhaoyun
.
sj
()
sunshangxiang
.
sj
()
sunshangxiang
.
sj
()
print
(
zhaoyun
.
hp
,
zhaoyun
.
name
)
#打印赵云的攻击力
def
sj
():
sunshangxiang
.
hp
+=
200
sunshangxiang
.
attack
+=
100
sunshangxiang
.
fangyu
+=
54
sj
()
print
(
sunshangxiang
.
hp
,
sunshangxiang
.
name
)
\ 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