Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_4
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
bb7426c5
authored
Feb 18, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
d2ceeb71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
diy2.py
diy2.py
View file @
bb7426c5
...
...
@@ -4,15 +4,17 @@ class Hero:
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
def
upgrade
(
self
):
self
.
hp
+=
60
self
.
level
+=
1
self
.
attack
+=
20
yase
=
Hero
(
"亚瑟"
,
300
,
20
)
hy
=
Hero
(
"后裔"
,
250
,
23
)
print
(
"亚瑟血量为:"
,
yase
.
hp
)
print
(
"后裔血量为:"
,
hy
.
hp
)
def
upgrade
():
yase
.
hp
+=
60
yase
.
level
+=
1
yase
.
attack
+=
20
self
=
Hero
(
"self"
,
250
,
23
)
for
i
in
range
(
14
):
upgrade
()
yase
.
upgrade
()
self
.
upgrade
()
print
(
"亚瑟血量为:"
,
yase
.
hp
)
print
(
"self血量为:"
,
self
.
hp
)
print
(
"亚瑟攻击为:"
,
yase
.
attack
)
print
(
"self攻击为:"
,
self
.
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