Transposed wheels in machine str
This commit is contained in:
@@ -18,16 +18,29 @@ class SlotMachine():
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = ""
|
string = ""
|
||||||
for wheel in self.wheels:
|
# Create an empty matrix with the sole purpose of transposing it
|
||||||
string += str(wheel) + "\n"
|
matrix = [[],[],[]]
|
||||||
|
|
||||||
|
for i, wheel in enumerate(self.wheels):
|
||||||
|
for icon in wheel.icons:
|
||||||
|
matrix[i].append(icon)
|
||||||
|
|
||||||
|
# Use Zip function to aggregate unpacked matrix (*matrix unpacks it)
|
||||||
|
matrix = zip(*matrix)
|
||||||
|
|
||||||
|
for row in matrix:
|
||||||
|
for icon in row:
|
||||||
|
string += str(icon) + " "
|
||||||
|
string += "\n"
|
||||||
|
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# machine = SlotMachine()
|
machine = SlotMachine()
|
||||||
# print(machine)
|
print(machine)
|
||||||
# machine.spin(randomness=1)
|
machine.spin()
|
||||||
# print(machine)
|
print(machine)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user