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
1b032a08
authored
Jun 18, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
1e1a9f56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
11 deletions
diy2.py
snake.py
diy2.py
View file @
1b032a08
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
def
a
(
self
):
self
.
level
=
self
.
level
+
1
self
.
hp
=
self
.
hp
+
20
self
.
attack
=
self
.
attack
+
10
lv
=
Hero
(
"lv"
,
300
,
50
)
lv
.
a
()
print
(
lv
.
hp
)
\ No newline at end of file
self
.
hp
=
250
self
.
attack
=
40
#def a(self):
#self.level=self.level+1
#self.hp=self.hp+20
#self.attack=self.attack+10
#lv=Hero("lv",300,50)
#lv.a()
#print(lv.hp)
def
combat
(
self
,
enemy
):
enemy
.
hp
-=
self
.
attack
info1
=
self
.
name
+
"dui"
+
enemy
.
name
+
"fa qi gong ji"
info2
=
"zaocheng"
+
str
(
self
.
attack
)
+
"dian shang hai"
if
enemy
.
hp
>
0
:
info3
=
enemy
.
name
+
"hai sheng"
+
str
(
enemy
.
hp
)
+
"hue"
info
=
info1
+
info2
+
info3
print
(
info
)
else
:
info3
=
enemy
.
name
+
"zheng wang"
info
=
info1
+
info2
+
info3
print
(
info
)
exit
()
class
Player
(
Hero
):
def
__init__
(
self
,
name
):
super
()
.
__init__
(
name
)
#self.level=1
#self.name=name
self
.
hp
=
200
self
.
attack
=
50
lb
=
Hero
(
"lb"
)
hx
=
Hero
(
"hx"
)
player
=
Player
(
"mm"
)
print
(
player
.
hp
)
\ No newline at end of file
snake.py
0 → 100644
View file @
1b032a08
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