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
0c9292bb
authored
Apr 15, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
3857c807
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
9 deletions
diy.py
diy.py
View file @
0c9292bb
class
hero
:
def
__init__
(
self
):
self
.
level
=
15
self
.
hp
=
99999999999999999999999999999999
self
.
attack
=
99999999999999999999999999999999
yase
=
hero
()
print
(
'yase的血量:'
,
yase
.
hp
)
print
(
'yase的攻击力:'
,
yase
.
attack
)
\ No newline at end of file
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
25
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
# yase = Hero('亚瑟',9999999,999999)
# jiji = Hero('吉吉',9999999,999999)
# print('亚瑟的血量:',yase.hp)
# print('吉吉的血量:',jiji.hp)
# def upgrade():
# yase.level=yase.level+1
# yase.hp=yase.hp+99999
# yase.attack=yase.attack+99999
# yase = Hero('亚瑟',9999999,999999)
# print('亚瑟的初始能量值为:',yase.hp)
# upgrade()
# upgrade()
# print('升级两次后,亚瑟的血量值为:',yase.hp)
def
upgrade
(
self
):
self
.
level
=
self
.
level
+
1
self
.
hp
=
self
.
hp
+
99999
self
.
attack
=
self
.
attack
+
99999
jiji
=
Hero
(
'吉吉'
,
9999999
,
999999
)
jiji
.
upgrade
()
jiji
.
upgrade
()
jiji
.
upgrade
()
print
(
'xl:'
,
jiji
.
hp
)
print
(
'dj:'
,
jiji
.
level
)
print
(
'gjl:'
,
jiji
.
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