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
d79942fb
authored
2 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
1bccff07
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
diy2.py
diy2.py
View file @
d79942fb
class
Hero
():
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
attack
=
attack
def
__init__
(
self
,
name
,
hp
,
attack
,
level
):
self
.
name
=
name
self
.
hp
=
hp
self
.
level
=
level
self
.
attack
=
attack
#yase=Hero('yase',300,20)
#hy=Hero('hy',250,23)
def
upgrade
(
self
):
...
...
@@ -14,6 +15,14 @@ class Hero():
print
(
self
.
hp
)
print
(
self
.
level
)
yase
=
Hero
(
100000
,
20000
,
1
)
yase
.
upgrade
()
yase
.
check
\ No newline at end of file
def
combat
(
self
,
enermy
):
enermy
.
hp
-=
self
.
attack
info1
=
self
.
name
+
"对"
+
enermy
.
name
+
"发动了攻击
\n
"
info2
=
enermy
.
name
+
"血量降低了"
+
str
(
self
.
attack
)
+
"
\n
"
info3
=
enermy
.
name
+
"还剩余"
+
str
(
enermy
.
hp
)
+
"点的血量
\n
"
print
(
info1
+
info2
+
info3
)
yase
=
Hero
(
"亚瑟"
,
200
,
40
,
1
)
houyi
=
Hero
(
"后羿"
,
200
,
400
,
2
)
houyi
.
combat
(
yase
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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