You need to create a map class to represent the game map in the pyramid. Create a Deck class to represent a deck of cards in the pyramid. So I wrote the code, but the teacher says that you need to implement this class using design patterns, please help.
import random class Card(object): def __init__(self): self.list = ['в™*', 'в™Ј', '♥', '♦'] self.cards = [] self.cart = [] for card_num in range(0, 52): r = str(card_num % 13) if r == '0': r = 'K' if r == '1': r = 'A' if r == '12': r = 'Q' if r == '11': r = 'J' index = int((card_num / 13) % 13) self.cards.append((r, self.list[index])) def draw(self): next = self.cards.pop(random.randint(0, len(self.cards) - 1)) return next def deck(self): c = Card() for i in range(0, 52): self.cart.append(c.draw()) print(30*' ',self.cart[0]) print(25*' ',self.cart[1:3]) print(20*' ',self.cart[4:7]) print(15*' ',self.cart[7:11]) print(10*' ',self.cart[11:16]) print(5*' ',self.cart[16:22]) print(self.cart[23:30]) print(30 * "---") print(self.cart[31:]) c = Card() c.deck() The deck must be a singleton. Also, the deck has to implement an iterator that produces current maps. Also, as far as I understand, maps have rozpihatsya in the rows of the pyramid, then each row can be created through the class factory. And the output of each line through the decorator.