-
Notifications
You must be signed in to change notification settings - Fork 1
/
class_rolling_dices.py
71 lines (64 loc) · 1.7 KB
/
class_rolling_dices.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# ROLLING DICES
# the program asks the number of dices to play
# Made by Ketan Singh
import random
class RandomDices:
def __init__(self) -> None:
self.dices = [[
'+---+',
'| |',
'| o |',
'| |',
'+---+',
],
[
'+---+',
'|o |',
'| |',
'| o|',
'+---+',
],
[
'+---+',
'|o |',
'| o |',
'| o|',
'+---+',
],
[
'+---+',
'|o o|',
'| |',
'|o o|',
'+---+',
],
[
'+---+',
'|o o|',
'| o |',
'|o o|',
'+---+',
],
[
'+---+',
'|o o|',
'|o o|',
'|o o|',
'+---+',
]
]
def rolling(self, num_of_dices):
dict_chosen_dice = {}
for i in range(num_of_dices):
dict_chosen_dice[i] = random.randint(0, 5)
for i in range(5):
for j in range(num_of_dices-1):
print(self.dices[dict_chosen_dice[j]][i], end=' ')
print(self.dices[dict_chosen_dice[num_of_dices-1]][i])
roll_dices = RandomDices()
while True:
a = input("How many dices you want to play? ('x' to exit) > ")
if a.lower() != 'x':
roll_dices.rolling(int(a))
else:
break