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
194c0c89
authored
Jan 08, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
8e5cfffc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
diy.py
diy.py
View file @
194c0c89
...
...
@@ -7,10 +7,18 @@ class Hero:
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
#定义一个升级功能的函数upgrade,让等级每升一级,血量加50,攻击力加4
def
upgrade
():
yase
.
level
=
yase
.
level
+
1
yase
.
hp
+=
50
yase
.
attack
+=
4
#实例对象yase,houyi
yase
=
Hero
(
'亚瑟'
,
300
,
20
)
houyi
=
?
#打印yase的血量hp
upgrade
()
upgrade
()
#houyi=?
#打印yase的upgrade()血量hp
print
(
'亚瑟的血量为:'
+
str
(
yase
.
hp
))
#打印houyi的血量hp
print
(
'后裔的血量为:'
+
str
(
houyi
.
hp
))
\ No newline at end of file
#print('后裔的血量为:'+str(houyi.hp))
\ 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