Created
October 22, 2020 13:29
-
-
Save fernandoc1/b833e09bbdc3455810c56b4b8dc470ad to your computer and use it in GitHub Desktop.
Teste da Monetizze
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python3 | |
import random | |
class Bet: | |
def __init__(self, numberAmount, totalBets): | |
self.numberAmount = numberAmount | |
self.result = None | |
self.totalBets = totalBets | |
betList = [] | |
for i in range(self.totalBets): | |
betList.append(self._createArray()) | |
self.bets = betList | |
@property | |
def numberAmount(self): | |
return self._numberAmount | |
@numberAmount.setter | |
def numberAmount(self, a): | |
if(a < 6) or (a > 10): | |
raise ValueError('Amount out of limits') | |
self._numberAmount = a | |
@property | |
def result(self): | |
return self._result | |
@result.setter | |
def result(self, a): | |
self._result = a | |
@property | |
def totalBets(self): | |
return self._totalBets | |
@totalBets.setter | |
def totalBets(self, a): | |
self._totalBets = a | |
@property | |
def bets(self): | |
return self._bets | |
@bets.setter | |
def bets(self, a): | |
self._bets = a | |
def _createArray(self): | |
rangeList = list(range(1,61)) | |
random.shuffle(rangeList) | |
randomList = rangeList[0:self.numberAmount] | |
randomList.sort() | |
return randomList | |
def draw(self): | |
rangeList = list(range(1,61)) | |
random.shuffle(rangeList) | |
randomList = rangeList[0:6] | |
randomList.sort() | |
self.result = randomList | |
def checkResults(self): | |
betsWon = [] | |
for bet in self.bets: | |
count = 0 | |
for num in bet: | |
if(num in self.result): | |
count += 1 | |
betsWon.append(count) | |
resp = "<table><tr><th>BET</th><th>AMOUNT</th></tr>" | |
for i in range(len(betsWon)): | |
resp += "<tr><td>" + str(self.bets[i]) + "</td><td>" + str(betsWon[i]) + "</td></tr>" | |
resp += "</table>" | |
return resp | |
x = Bet(10, 6) | |
x.draw() | |
print("<html><body><p>DRAW: " + str(x.result) + "</p>") | |
print(x.checkResults()) | |
print("</body></html>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment