import stdlib;
using stdlib;
class Point
{
method Point()
{
x = 0;
y = 0;
}
method Point( int X, int Y )
{
x = X;
y = Y;
}
method out()
{
printf("Point members are %d, %d\n", {x, y});
}
int x;
int y;
}
class Rect
{
method Rect()
{
tl = new Point();
br = new Point();
}
method Rect( const Point topLeft, const Point bottomRight )
{
tl = topLeft;
br = bottomRight;
}
method Rect( int left, int top, int right, int bottom )
{
tl = new Point(left, top);
br = new Point(right, bottom);
}
method int isInside( const Point p )
{
return (p.x >= tl.x && p.x < br.x && p.y >= tl.y && p.y < br.y);
}
method out()
{
printf("Rect members are %d, %d, %d, %d\n", {tl.x, tl.y, br.x, br.y});
}
Point tl;
Point br;
}
function string main(const string[] args)
{
print("* Creating a Rect with coords 50,50,200,200\n");
Rect aRect = new Rect(50, 50, 200, 200);
aRect.out();
print("* Setting Rect members to coords 60,40,150,250\n");
aRect.tl.x = 60;
aRect.tl.y = 40;
aRect.br.x = 150;
aRect.br.y = 250;
aRect.out();
print("* Creating Point A with coords 32,48\n");
Point A = new Point(32, 48);
A.out();
print("* Creating Point B with coords 64,96\n");
Point B = new Point(64, 96);
B.out();
if( aRect.isInside(A) )
print("Point A is inside the Rect.\n");
else
print("Point A is NOT inside the Rect.\n");
if( aRect.isInside(B) )
print("Point B is inside the Rect.\n");
else
print("Point B is NOT inside the Rect.\n");
print("* Assigning Point A to B.\n");
B = A;
B.out();
if( aRect.isInside(B) )
print("Point B is inside the Rect.\n");
else
print("Point B is NOT inside the Rect.\n");
return "Done.";
}