So here’s my code:
class Board:
def __init__ (self, boardLength, boardHeight, pieces):
self.__boardLength = boardLength
self.__boardHeight = boardHeight
self.__pieces = pieces
self.__snapShots = []
self.__tiles = []
while len(self.__tiles) < (self.__boardHeight*self.__boardLength):
self.__tiles.append(0)
board1 = Board(5, 4,
[u,I_shape(1,'I'),X_shape(3,5,'U'),T_shape(4,5,'U'),L_shape(3,5,'U')]
)
and I get this:
TypeError: __init__() takes exactly 4 arguments (3 given)
I understand that init take 4 arguements, but one of them is self and I gave it the other three. Can anyone tell me what im doing wrong?
I imagine your problem is actually in
I_shape, given your other shapes all take 3 arguments. I ran this and it worked fine, replacing the classes that don’t exist withNone.Also, it’s worth noting that using name mangling (
__variable) is not needed 99.9% of the time. Use a single underscore if you want to indicate it’s private.