A Little Late to “Class”

Nick Kunz
Data Mining the City
1 min readOct 26, 2017

Although this exercise occurred a little bit out of sequence. I found it to be helpful not just to become more familiar with the classes and objects, but utilizing the multiple windows in Python. This was something I had curiosities about and this help to clarify them. I look forward to utilizing this convention in the future, as well as familiarize myself more with Python’s fundamental features concerning classes and objects. Above you can find the output and below you can find the code.

Window A: windowsketch2

class Window(object):

def __init__(self, x, y, windowWidth, windowHeight, bar):
self.x = x
self.y = y
self.windowWidth = windowWidth
self.windowHeight = windowHeight
self.bar = bar

def area(self):
return self.windowWidth * self.windowHeight

def draw(self):
if self.x < mouseX and mouseX < self.x + self.windowWidth:
fill(0)
else:
fill(self.bar)
fill(128, 128, 128)
rect(self.x, self.y, self.windowWidth, self.windowHeight)
rect(self.x, self.y, self.windowWidth, self.windowHeight)

Window B: window.py

from window import *def setup():
size(800, 450)

global window_1
window_1 = Window(10, 10, 12, 30, color(128, 128, 128))

print window_1.windowWidth
print window_1.area()

global buildingWindows
buildingWindows = []

for w in xrange(5, 150, 5):
window = Window(w * 13, 0, w, 450, color(128, 128, 128))
buildingWindows.append(window)

def draw():
background(0)

for window in buildingWindows:
window.draw()

--

--