import random
# 前世
class PastLife:
def __init__(self, name, profession, life, causeOfDeath):
self.name = name
self.profession = profession
self.life = life
self.causeOfDeath = causeOfDeath
def __str__(self):
return "您的前世是" + self.profession + self.name + "活了" + str(
self.life) + "岁.您前世死于" + self.causeOfDeath
# 今生
class ThisLife:
def __init__(self, name, sex):
self.name = name
self.sex = sex
# 穿越
def passThrough(self):
i = random.randint(0, 3)
if i == 0:
pastLife = PastLife("孙尚香", "郡主", 64, "自尽")
elif i == 1:
pastLife = PastLife("张飞", "车骑将军", 53, "谋杀")
elif i == 2:
pastLife = PastLife("诸葛亮", "孔明先生", 60, "气死")
else:
pastLife = PastLife("荀彧", "大聪明", 57, "老死")
return pastLife
def main():
thisLife = ThisLife(input("请输入你的姓名:"), input("请输入您的性别(男或女):"))
p = thisLife.passThrough()
print("天灵灵!地灵灵!太上老君急急如律令......", p)
main()
暂无评论