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
8be35163
authored
Apr 15, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
2bd06260
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
14 deletions
diy.py
diy.py
View file @
8be35163
...
@@ -4,19 +4,36 @@ class Hero:
...
@@ -4,19 +4,36 @@ class Hero:
self
.
name
=
name
self
.
name
=
name
self
.
hp
=
hp
self
.
hp
=
hp
self
.
attack
=
attack
self
.
attack
=
attack
yase
=
Hero
(
"亚瑟"
,
99999999998
,
99999998
)
# yase = Hero("亚瑟",99999999998,99999998)
kunkun
=
Hero
(
"坤坤"
,
99999999998
,
99999998
)
# kunkun = Hero("坤坤",99999999998,99999998)
print
(
"亚瑟的血量:"
,
yase
.
hp
)
# print("亚瑟的血量:",yase.hp)
print
(
"坤坤的血量:"
,
kunkun
.
hp
)
# print("坤坤的血量:",kunkun.hp)
def
upgrade
():
# def upgrade():
yase
.
level
=
yase
.
level
+
1
# yase.level=yase.level+1
yase
.
hp
=
yase
.
hp
+
1
# yase.hp=yase.hp+1
yase
.
attack
=
yase
.
attack
+
1
# yase.attack=yase.attack+1
yase
=
hero
(
"亚瑟"
,
99999999999
,
99999999
)
# yase = hero("亚瑟",99999999999,99999999)
print
(
"亚瑟的初始血量:"
,
yase
.
hp
)
# print("亚瑟的初始血量:",yase.hp)
upgrade
()
# upgrade()
upgrade
()
# upgrade()
print
(
"升级两次后,yase的血量为:"
,
yase
.
hp
)
# print("升级两次后,yase的血量为:",yase.hp)
def
upgrade
(
self
):
self
.
level
=
self
.
level
+
1
self
.
hp
=
self
.
hp
+
1
self
.
attack
=
self
.
attack
+
1
houyi
=
Hero
(
"坤坤"
,
99999999999999999999999999
,
9999999999999999999999999999999999
)
houyi
.
upgrade
()
print
(
"等级:"
,
houyi
.
level
)
print
(
"血量:"
,
houyi
.
hp
)
print
(
"攻击力:"
,
houyi
.
attack
)
\ 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