|
using System;
namespace CChess
{
public class CChessSquare
{
public CChessSquare(byte ring, byte square)
{
_ring = ring;
_square = square;
}
private byte _ring;
private byte _square;
public byte Ring
{
get { return _ring; }
}
public byte Square
{
get { return _square; }
}
/// <summary>
/// Gets the color of the square.
/// </summary>
public CChessColors Color
{
get
{
if (_ring % 2 == 0)
{
if (_square % 2 == 0)
{
return CChessColors.White;
}
else
{
return CChessColors.Black;
}
}
else
{
if (_square % 2 == 0)
{
return CChessColors.Black;
}
else
{
return CChessColors.White;
}
}
}
}
public override bool Equals(object right_hand)
{
if (right_hand == null)
{
return false;
}
if (ReferenceEquals(this, right_hand))
{
return true;
}
CChessSquare right_square = right_hand as CChessSquare;
if (right_square == null)
{
return false;
}
return ((_square == right_square.Square) && (_ring == right_square.Ring));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
My name is Julian, I was born in Argentina, but I've been living in Israel for 6 years already. I'm a high school student in my last year, I study computer science, physics and math.
Other than programming, I really enjoy watching anime and reading manga.