Добавил:
Kolobok
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Для специальностей ПМИ-ПМ. Лаба 2 вариант 6 / Zad2 / SQUARE
.CPP#include "SQUARE.H"
//#include "Math.h"
#ifndef _SQUARE_TA_CPP_12843721983472171
#define _SQUARE_TA_CPP_12843721983472171
TSquare::TSquare (int xx, int yy, int ww) //Constructor;
{
SetX(xx);
SetY(yy);
SetWidth(ww);
};
int TSquare::GetX () //;
{
return x;
};
int TSquare::GetY () //;
{
return y;
};
int TSquare::GetWidth () //;
{
return width;
};
int TSquare::SetX (int xx) //;
{
x=xx;
return 0;
};
int TSquare::SetY (int yy) //;
{
y=yy;
return 0;
};
int TSquare::SetWidth (int ww) //;
{
if (ww>4) {width=ww;return 0;}
return 1;
};
TSquare operator - (TSquare a,TSquare b) //Operator -
{
TSquare c;
c.x=a.x-b.x;
c.y=a.y-b.y;
c.width=abs(a.width-b.width)+20;
return c;
}
TSquare operator + (TSquare a,TSquare b) //Operator +
{
TSquare c;
c.x=a.x+b.x;
c.y=a.y+b.y;
c.width=(a.width+b.width)-20;
return c;
}
TSquare TSquare::Paint (int c) //Draw;
{
setcolor(c);
setfillstyle(1,c);
rectangle(x-width/2,y-width/2,x+width/2,y+width/2);
bar(x-width/2+2,y-width/2+2,x+width/2-2,y+width/2-2);
return *this;
}
#endif //_SQUARE_TA_CPP_12843721983472171