Commit 519ebef8 by BellCodeEditor

save project

parent d7953df9
Showing with 15 additions and 5 deletions
with open(r"C:\Users\qinlp\Desktop\sales_list.txt","r", encoding="utf-8") as file: class Hero:
file2=file.readlines() def __init__(self,name):
for i in file2: self.level=1
print(i) self.hp=200
\ No newline at end of file self.attack=40
self.name=name
def combat(self,a):
print(self.name+"对"+a.name+"发起了攻击")
print("对"+a.name+"造成了"+str(self.attack)+"点伤害")
a.hp=a.hp-self.attack
print(a.name+"还剩下"+str(a.hp)+"滴血")
hero1=Hero("亚瑟")
hero2=Hero("后羿")
hero1.combat(hero2)
\ No newline at end of file
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