【发布时间】:2022-09-23 01:43:34
【问题描述】:
Rock, Paper, Scissors 变量 bot 具有默认值 变量 Alex,具有传递给 main.py 的值 当我调用方法比较时出现错误 方法比较 从秘密进口选择 从变体导入变体
播放器.py
class Player:
name = \'\',
choice = \'\'
def __init__(self, choise = \'ROCK\', name = \'bot\'):
self.name = name
self.choice = choice
def whoWins(self, bot, alex):
if bot.choice > alex.choice:
print(\'bot, winner\')
if bot.choice < alex.choice:
print(\'Alex, winner\')
if bot.choice == alex.choice:
print(\'draw\')
主文件
from variants import Variants
from player import Player
bot = Player()
alex = Player(Variants.ROCK, \"Alex\")
print(bot.whoWins(bot, alex))
变体.py
from enum import Enum
class Variants(Enum):
ROCK = 1,
PAPER = 2,
SCISSORS = 3