Exemplo n.º 1
0
    def render(self, grid: Grid, **kwargs: Any) -> None:
        output = '+' + '---+' * grid.cols + '\n'

        for row in grid.eachRow():
            top = '|'
            bottom = '+'
            for cell in row:
                # NOTE: Book here creates dummy (-1,-1) cell. Not doing it until needed
                body = grid.contents(cell)
                east_boundary = ' ' if cell & cell.east else '|'
                top += body + east_boundary
                south_boundary = '   ' if cell & cell.south else '---'
                corner = '+'
                bottom += south_boundary + corner
            output += top + '\n'
            output += bottom + '\n'

        print(output)
    def render(self, grid: Grid, **kwargs: Any) -> None:
        horizontal_wall = '\u2501'
        vertical_wall = '\u2503'

        output = self.JUNCTIONS[12]
        for x in range(grid.cols - 1):
            output += (horizontal_wall * 3 +
                       self.get_topmost_junction(cast(Cell, grid[0, x])))
        output += horizontal_wall * 3 + self.JUNCTIONS[10] + '\n'

        for row in grid.eachRow():
            top = vertical_wall
            bottom = self.get_leftmost_junction(row[0])
            for cell in row:
                body = grid.contents(cell)
                east_boundary = ' ' if cell & cell.east else vertical_wall
                top += body + east_boundary
                south_boundary = '   ' if cell & cell.south else horizontal_wall * 3
                bottom += south_boundary + self.get_south_east_junction(cell)
            output += top + '\n'
            output += bottom + '\n'

        print(output)