Exemple #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__()
Exemple #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)
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()
Exemple #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])
 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()