import random class students: def __init__(self): self.computerfist=random.randint(1,3) def play(self): if my_fist>self.computerfist: print("我赢了") elif my_fist==self.computerfist: print("平局") elif my_fist<self.computerfist: print("我输了") n=0 while n<=3: my_fist=int(input("请输入1~3之间的数")) a=students() a.play() n+=1
通过面向对象思 想实现人机猜数小游戏
最新推荐文章于 2024-07-21 22:27:18 发布