Comparing Coffee Shops

Masha Konopleva
Data Mining the City
1 min readOct 9, 2017
#main sketch
from coffee import *
def setup():
size(500,500)

global coffee_1
coffee_1 = Coffee(150, True, False, 2)
global coffee_2
coffee_2 = Coffee(350, False, True, 3)
def draw():
background(255,225,240)
fill(255)
rect(50,450,100,25)
rect(200, 450, 100, 25)
rect(350, 450, 100, 25)
fill(0)
text('wi-fi?', 80, 465)
text('restroom?', 225, 465)
text('price?', 380, 465)
text("DUNKIN' DONUTS", 100, 75)
text("STARBUCKS", 320, 75)


if (mouseX>50 and mouseX<150 and mouseY>400):
coffee_1.drawwifi()
coffee_2.drawwifi()
elif (mouseX>200 and mouseX<300 and mouseY>400):
coffee_1.drawrr()
coffee_2.drawrr()
elif (mouseX>350 and mouseX<450 and mouseY>400):
fill(0, 0, 0)
coffee_1.drawprice()
coffee_2.drawprice()
else:
text('select category', 220, 490)

and the class

class Coffee(object):

def __init__(self, x, wifi, restroom, price):
self.x = x
self.wifi = wifi
self.restroom = restroom
self.price = price

def drawwifi(self):
if self.wifi:
line(self.x,150,self.x+20,130)
line(self.x,150,self.x-10,140)
else:
line(self.x+10,160,self.x-10,140)
line(self.x-10,160,self.x+10,140)

def drawrr(self):
if self.restroom:
line(self.x,150,self.x+20,130)
line(self.x,150,self.x-10,140)
else:
line(self.x+10,160,self.x-10,140)
line(self.x-10,160,self.x+10,140)

def drawprice(self):
fill(0,128,0)
ellipse(self.x, height/2, self.price*30, self.price*30)

--

--