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
493a67b1
authored
Dec 21, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
d4ac94c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
diy.py
l.py
diy.py
View file @
493a67b1
class
hero
:
class
hero
:
def
__init__
(
self
,
hp
,
attack
):
def
__init__
(
self
,
hp
,
attack
):
self
.
level
=
1
self
.
level
=
1
#self.name=name
self
.
hp
=
hp
self
.
hp
=
hp
self
.
attack
=
attack
self
.
attack
=
attack
#yase=hero(200,300)
#yase.hp=250 #变量里的数值取决于最后一次赋值内容
def
upgrade
(
self
):
self
.
level
=
self
.
level
+
1
self
.
hp
=
self
.
hp
+
50
self
.
attack
=
self
.
attack
+
20
daji
=
hero
(
300
,
200
)
yase
=
hero
(
200
,
300
)
yase
.
upgrade
()
for
i
in
range
(
1
,
10
):
print
(
yase
.
attack
)
daji
.
level
=
i
daji
.
attack
=
daji
.
attack
+
100
daji
.
hp
=
daji
.
hp
+
50
print
(
daji
.
hp
)
\ No newline at end of file
l.py
View file @
493a67b1
...
@@ -3,13 +3,11 @@ class hero:
...
@@ -3,13 +3,11 @@ class hero:
self
.
level
=
1
self
.
level
=
1
self
.
hp
=
hp
self
.
hp
=
hp
self
.
hk
=
hk
self
.
hk
=
hk
ye
=
hero
(
100
,
12
)
ye
.
hp
=
300
def
upgrade
(
self
):
print
(
ye
.
hp
)
self
.
level
=
self
.
level
+
1
self
.
hp
=
self
.
hp
+
50
def
upgrade
(
self
):
self
.
hk
=
self
.
hk
+
30
self
.
level
=
self
.
level
+
1
ye
=
hero
(
100
,
20
)
self
.
hp
=
self
.
hp
+
50
upgrade
(
ye
)
self
.
hk
=
self
.
hk
+
30
print
(
ye
.
hp
)
upgrade
(
ye
)
\ No newline at end of file
print
(
ye
.
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