Last active
August 29, 2015 14:26
-
-
Save micaiahparker/a60423e9cf25c73088bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Grid(): | |
def __init__(self, rows, cols, fill = 0): | |
self.rows = rows | |
self.cols = cols | |
self.fill = fill | |
self.grid = self.make_grid(self.rows, self.cols, self.fill) | |
def make_grid(self, rows, cols, fill): | |
#return [[self.fill for col in range(self.cols)] for row in range(self.rows)] | |
local = [] | |
for row in range(self.rows): | |
local.append([]) | |
for row in range(self.rows): | |
for col in range(self.cols): | |
local[row].append(self.fill) | |
return local | |
def display(self): | |
for row in self.grid: | |
print(row) | |
def main(): | |
main_grid = Grid.make_grid(3,3,Grid(10,10)) #makes a 3x3 grid filled with 10x10 Grid objects | |
print(main_grid[4][5].grid[2][4]) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment