Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_3
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
311a5018
authored
May 29, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
5f43c146
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
diy2.py
diy2.py
View file @
311a5018
...
...
@@ -4,15 +4,24 @@ class Hero:
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
yase
=
Hero
(
'亚瑟'
,
3648
,
224
)
houyi
=
Hero
(
'后羿'
,
2674
,
276
)
print
(
yase
.
hp
)
print
(
houyi
.
hp
)
def
upgrade
():
yase
.
level
=
yase
.
level
+
1
yase
.
hp
=
yase
.
hp
+
500
yase
.
attack
=
yase
.
attack
+
80
upgrade
()
print
(
yase
.
hp
)
print
(
houyi
.
hp
)
def
upgrade
(
self
):
self
.
level
=
self
.
level
+
1
self
.
hp
=
self
.
hp
*
1.2
self
.
attack
=
self
.
attack
*
1.2
yase
=
Hero
(
'亚瑟'
,
3600
,
224
)
houyi
=
Hero
(
'后羿'
,
2600
,
276
)
print
(
'亚瑟的等级是'
,
yase
.
level
)
print
(
'亚瑟的血量是'
,
yase
.
hp
)
print
(
'亚瑟的攻击是'
,
yase
.
attack
)
print
(
'后羿的等级是'
,
houyi
.
level
)
print
(
'后羿的血量是'
,
houyi
.
hp
)
print
(
'后羿的攻击是'
,
houyi
.
attack
)
yase
.
upgrade
()
houyi
.
upgrade
()
print
(
'亚瑟的等级是'
,
yase
.
level
)
print
(
'亚瑟的血量是'
,
yase
.
hp
)
print
(
'亚瑟的攻击是'
,
yase
.
attack
)
print
(
'后羿的等级是'
,
houyi
.
level
)
print
(
'后羿的血量是'
,
houyi
.
hp
)
print
(
'后羿的攻击是'
,
houyi
.
attack
)
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