Skip to content

Instantly share code, notes, and snippets.

@ssbb
Created March 13, 2015 23:19
Show Gist options
  • Save ssbb/d8ad6705a648c8a8ef7e to your computer and use it in GitHub Desktop.
Save ssbb/d8ad6705a648c8a8ef7e to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import random
class Dot(object):
def __init__(self, x, y):
self.coords = [x, y]
class Line(object):
def __init__(self, d1, d2):
self.dots = [d1, d2]
class Rectangle(object):
def __init__(self, l1, l2, l3, l4):
self.lines = [l1, l2, l3, l4]
def get_dots(self):
for line_index, line in enumerate(self.lines):
print 'Line %d' % (line_index + 1, )
for dot_index, dot in enumerate(line.dots):
print '\tDot %d\n\t\tX:%d\n\t\tY:%d' % (
dot_index,
dot.coords[0],
dot.coords[1])
lines = []
for i in xrange(4):
d1 = Dot(random.randint(0, 10), random.randint(0, 10))
d2 = Dot(random.randint(0, 10), random.randint(0, 10))
lines.append(Line(d1, d2))
rect = Rectangle(*lines)
print rect.get_dots()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment