I'm a little rusty on Java, so my example will be in C++.
Code:
class piece
{
public:
bool moveTo(x,y);
bool isThreatend();
TYPE pieceType();
private:
COLOR color;
}
class pawn : piece
{
private:
bool EnPassante;
}
pawn myPawn;
piece myPiece;
myPiece has one data values: myPiece.color
myPawn has two data value: myPawn.color (inherited from the piece class) and myPawn.EnPassante
COLOR is an enumeration for the colors of chess pieces (Black and White).
Now I can make another class:
Code:
class Board
{
public:
void PlayGame();
private:
piece pieces[16][2];
}
This class has 32 pieces as data, each having a color and the ability to move.
Now, with a few more classes and some code for the methods, you have a chess program
