#include "rect.h"

m_rect::m_rect()
{
    top = 0;
    bot = 0;
    left = 0;
    right = 0;
}

m_rect::m_rect(int _top, int _bot, int _left, int _right)
{
    top = _top;
    bot = _bot;
    left = _left;
    right = _right;
}

int m_rect::intersects(m_rect const &other) const
{
    int
	left_right = 0,
	top_bot = 0;

    if (
	(other.left >= left && other.left <= right)
	||
	(other.right >= left && other.right <= right)
	||
	(other.left <= left && other.right >= right)
       )
    {
	left_right = 1;
    }

    if (
	(other.top >= top && other.top <= bot)
	||
	(other.bot >= top && other.bot <= bot)
	||
	(other.top <= top && other.bot >= bot)
       )
    {
	top_bot = 1;
    }

    return (left_right && top_bot);
}

