Commit f75268b3 by BellCodeEditor

auto save

parent 3a04fafa
Showing with 58 additions and 10 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
yase=Hero("亚瑟",3000,200)
houyi=Hero("后羿",2400,230)
print("亚瑟的血量值为:",yase.hp)
print("后羿的攻击力为:",yase.hp)
\ No newline at end of file
username="python" # 保存在服务器数据库中的用户账号(正确的账号) for i in range(1,1000):
userpassword="123456" # 保存在服务器数据库中的用户密码(正确的密码) for j in range(1,i+1000):
name=input("请输入用户账号") print(j,'*',i,'=',(j*i), end=" ")
# 请用input(1233)实现用户输入账号、密码的功能 print()
password=input("请输入用户密码") \ No newline at end of file
if name==username and password == userpassword:
print("登入成功")
# 如果用户输入的账号、密码正确,提示登陆成功
\ No newline at end of file
...@@ -4,5 +4,5 @@ name=input("请输入用户账号") ...@@ -4,5 +4,5 @@ name=input("请输入用户账号")
# 请用input(1233)实现用户输入账号、密码的功能 # 请用input(1233)实现用户输入账号、密码的功能
password=input("请输入用户密码") password=input("请输入用户密码")
if name==username and password == userpassword: if name==username and password == userpassword:
print("登成功") print("登成功")
# 如果用户输入的账号、密码正确,提示登陆成功 # 如果用户输入的账号、密码正确,提示登陆成功
\ No newline at end of file
class Hero:
def __init__(self,name):
self.level=1
self.hp=250
self.attack=40
self.name=name
def combat(self,enemy):
info1=self.name+"对"+enemy.name+"发起进攻"
info2="造成"+str(self.attack)+"点伤害"
enemy.hp-=self.attack
if enemy.hp>0:
info3=enemy.name+"还剩下"+str(enemy.hp)+"血量"
info=info1+info2+info3
print(info)
else:
info3=enemy.name+"阵亡,游戏结束"
info=info1+info2+info3
print(info)
exit()
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp=200
self.attack=50
player=Player("后羿")
print("玩家的血量值为:",player.hp)
print("玩家的攻击力为:",player.attack)
# yase=Hero("垭瑟")
# houyi=Hero("后羿")
# yase.combat(houyi)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment