Listing 1
/*1*/
using namespace System;
/*2*/
public ref class Point
{
int x;
int y;
public:
// define read-write instance properties X and Y
/*3a*/ property int X
{
/*3b*/ int get() { return x; }
/*3c*/ void set(int val) { x = val; }
}
/*4a*/ property int Y
{
/*4b*/ int get() { return y; }
/*4c*/ void set(int val) { y = val; }
}
// define instance constructors
/*5a*/ Point()
{
/*5b*/ X = 0;
/*5c*/ Y = 0;
}
/*6a*/ Point(int xor, int yor)
{
/*6b*/ X = xor;
/*6c*/ Y = yor;
}
// define instance methods
/*7a*/ void Move(int xor, int yor)
{
/*7b*/ X = xor;
/*7c*/ Y = yor;
}
/*8a*/ virtual bool Equals(Object^ obj) override
{
/*8b*/ if (obj == nullptr)
{
return false;
}
/*8c*/ if (this == obj) // are we testing against ourselves?
{
return true;
}
/*8d*/ if (GetType() == obj->GetType())
{
/*8e*/ Point^ p = static_cast<Point^>(obj);
/*8f*/ return (X == p->X) && (Y == p->Y);
}
return false;
}
/*9*/ virtual int GetHashCode() override
{
return X ^ (Y << 1);
}
/*10a*/ virtual String^ ToString() override
{
/*10b*/ return String::Concat("(", X, ",", Y, ")");
}
};