# Kuviot kehiin
from math import pi


class Shape(object):

    def __init__(self, color):
        self.color = color

    def samecolor(self, other):
        return self.color == other.color

    def info(self):
        print(str(self))

    def compute_area(self):
        pass

    def intesects(self, othe):
        pass


class Ellipse(Shape):
    def __init__(self, center, a, b, color):
        super().__init__(color)
        self.center = center
        self.a = a
        self.b = b
        self.area = self.compute_area()

    def __str__(self):
        return '{}(center={}, a={}, b={}, color={})'
               .format(type(self).__name__, self.center, self.a, self.b, self.color)

    def compute_area(self):
        return pi * self.a * self.b


class Circle(Ellipse):

    def __init__(self, center, radius, color):
        super().__init__(center, radius, radius, color)
        self.radius = radius

    def __str__(self):
        return '{}(center={}, radius={}, color={})'.format(type(self).__name__, self.center, self.radius, self.color)


class Rectangle(Shape):

    def __init__(self, point1, point2, color):
        super().__init__(color)
        self.point1 = point1
        self.point2 = point2
        (x1, y1) = point1
        (x2, y2) = point2
        self.width = abs(x1 - x2)
        self.height = abs(y1 - y2)
        self.area = self.compute_area()

    def __str__(self):
        return '{}(point1={}, point2={}, color={})'.format(type(self).__name__, self.point1, self.point2, self.color)

    def compute_area(self):
        return self.width * self.height


class Square(Rectangle):

    def __init__(self, center, side, color):
        (x, y) = center
        super().__init__((x - side / 2, y - side / 2), (x + side / 2, y + side / 2), color)
        self.center = center
        self.side = side

    def __str__(self):
        return '{}(center={}, side={}, color={})'.format(type(self).__name__, self.center, self.side, self.color)


crimson = (0xDC, 0x14, 0x3C)
white = (0xFF, 0xFF, 0xFF)
indigo = (0x4B, 0x00, 0x82)

shapes = [Circle((10.0, 20.0), 2.5, crimson),
          Rectangle((-5.0, 5.0), (5.0, 5.0), white),
          Ellipse((0.0, -5.0), 7.5, 6.0, indigo),
          Circle((10.5, 19.5), 3.0, crimson),
          Square((5.0, -5.0), 8.5, white),
          Ellipse((6.0, 10.0), 7.5, 6.0, indigo),
          Square((20.0, 30.0), 10.0, indigo)]

for s in shapes:
    s.info()

for i in range(len(shapes)):
    for j in range(i + 1, len(shapes)):
        print('Muodot {} ja {} ovat {}väriset'.format(shapes[i], shapes[j], 'saman' if shapes[i].samecolor(shapes[j]) else 'eri'))
