Exemplo n.º 1
0
class Diagonal(object):
    def __init__(self, id, col_size, squares_args):
        self.id = id
        self.squares = []
        self.rule_engine = RowRulesEngine()

        if self.id == 0:
            start_index = 0
            stop_index = col_size
            step = 1
        else:
            start_index = col_size-1
            stop_index = -1
            step = -1

        for i in range(start_index, stop_index, step):
            index = i*col_size + len(self.squares)
            self.squares.append(squares_args[index])

    def run(self, *args, **kwargs):
        self.rule_engine.run(self, args, kwargs)

    def __str__(self):
        return 'Diagonal:'+str(self.squares)

    def __repr__(self):
        return self.__str__()
Exemplo n.º 2
0
class VerticalRow(object):
    def __init__(self, id, col_size, squares):
        self.id = id
        self.squares = [squares[index] for index in range(id, len(squares), col_size)]
        self.rule_engine = RowRulesEngine()

    def __str__(self):
        return 'vertical row:'+str(self.squares)

    def __repr__(self):
        return self.__str__()

    def setSquare(self, row_no, value):
        self.squares[row_no].setValue(value)
        self.run()

    def run(self, *args, **kwargs):
        self.rule_engine.run(self, args, kwargs)
Exemplo n.º 3
0
class HorizontalRow(object):
    def __init__(self, id, col_size, squares):
        self.id = id
        self.squares = [squares[index] for index in range(id * col_size, (id + 1) * col_size, 1)]
        self.rule_engine = RowRulesEngine()


    def run(self, *args, **kwargs):
        self.rule_engine.run(self, args, kwargs)

    def __str__(self):
        return 'horizontal row:'+str(self.squares)

    def __repr__(self):
        return self.__str__()

    def setSquare(self, col, value):
        self.squares[col].setValue(value)
        self.run()
Exemplo n.º 4
0
    def __init__(self, id, col_size, squares_args):
        self.id = id
        self.squares = []
        self.rule_engine = RowRulesEngine()

        if self.id == 0:
            start_index = 0
            stop_index = col_size
            step = 1
        else:
            start_index = col_size-1
            stop_index = -1
            step = -1

        for i in range(start_index, stop_index, step):
            index = i*col_size + len(self.squares)
            self.squares.append(squares_args[index])
Exemplo n.º 5
0
 def __init__(self, id, col_size, squares):
     self.id = id
     self.squares = [squares[index] for index in range(id * col_size, (id + 1) * col_size, 1)]
     self.rule_engine = RowRulesEngine()