Example #1
0
def menuInsertParticipantAtPosition(scoreList):
    s1 = utilities.readInteger("Score 1: ")
    s2 = utilities.readInteger("Score 2: ")
    s3 = utilities.readInteger("Score 3: ")
    pos = utilities.readInteger("Position: ")

    printCommandResult(commands.insertAtPosition(scoreList, [str(s1), str(s2), str(s3), 'at', str(pos)]))
Example #2
0
def menuListCommand(scoreList):
    sign = readCommand("Sign (<, =, >): ")
    score = utilities.readInteger("Score: ")

    # sign[0], because readCommand returns a command name and the arguments
    # hacks everywhere
    printCommandResult(commands.listCommand(scoreList, [sign[0], str(score)]))
Example #3
0
def runMenu():
    scoreList = []

    # used for testing
    testInsertValuesNoOrder(scoreList)

    while True:
        printMenu()

        option = utilities.readInteger(">> ")
        if option == 1:
            menuAddParticipantToList(scoreList)
        elif option == 2:
            menuInsertParticipantAtPosition(scoreList)
        elif option == 3:
            menuRemoveParticipantAtPosition(scoreList)
        elif option == 4:
            menuRemoveFromIToJ(scoreList)
        elif option == 5:
            menuReplaceScore(scoreList)
        elif option == 6:
            printCommandResult(commands.listCommand(scoreList, ""))
        elif option == 7:
            printCommandResult(commands.listCommand(scoreList, ["sorted"]))
        elif option == 8:
            menuListCommand(scoreList)
        elif option == 9:
            menuAvgScores(scoreList)
        elif option == 10:
            menuMinScores(scoreList)
        elif option == 11:
            menuTopNCommand(scoreList)
        elif option == 12:
            menuTopNCommandByProblemId(scoreList)
        elif option == 13:
            menuRemoveLessEquGreaterThan(scoreList)
        elif option == 14:
            printCommandResult(commands.undo(scoreList, ""))
        elif option == 15:
            exit()
        else:
            print("Unknown option!")
Example #4
0
def menuTopNCommand(scoreList):
    participantsLimit = utilities.readInteger("How many participants do you want to see? ")

    printCommandResult(commands.topCommand(scoreList, [str(participantsLimit)]))
Example #5
0
def menuTopNCommandByProblemId(scoreList):
    participantsLimit = utilities.readInteger("How many participants do you want to see? ")
    problemNo = utilities.readInteger("Problem number (1, 2, 3): ")

    printCommandResult(commands.topCommand(scoreList, [str(participantsLimit), 'P' + str(problemNo)]))
Example #6
0
def menuRemoveLessEquGreaterThan(scoreList):
    sign = readCommand("Sign (<, =, >): ")
    score = utilities.readInteger("Score: ")

    printCommandResult(commands.removeLessEquGreaterThan(scoreList, sign[0], score))
Example #7
0
def menuRemoveFromIToJ(scoreList):
    pos1 = utilities.readInteger("Position 1: ")
    pos2 = utilities.readInteger("Position 2: ")

    printCommandResult(commands.removeFromIToJ(scoreList, pos1, pos2))
Example #8
0
def menuRemoveParticipantAtPosition(scoreList):
    pos = utilities.readInteger("Position: ")

    printCommandResult(commands.removeFromPosition(scoreList, pos))
Example #9
0
def menuAddParticipantToList(scoreList):
    s1 = utilities.readInteger("Score 1: ")
    s2 = utilities.readInteger("Score 2: ")
    s3 = utilities.readInteger("Score 3: ")

    printCommandResult(commands.addScore(scoreList, [str(s1), str(s2), str(s3)]))
Example #10
0
def menuReplaceScore(scoreList):
    pos = utilities.readInteger("Position: ")
    problemNo = utilities.readInteger("Problem number (1, 2, 3): ")
    score = utilities.readInteger("Score: ")

    printCommandResult(commands.replaceScore(scoreList, [str(pos), 'P' + str(problemNo), 'with', str(score)]))
Example #11
0
def menuAvgScores(scoreList):
    pos1 = utilities.readInteger("Position 1: ")
    pos2 = utilities.readInteger("Position 2: ")

    printCommandResult(commands.avgScores(scoreList, [str(pos1), 'to', str(pos2)]))