I have faced a problem while designing chess game.
There are 2 Player: p1, p2;
I want to implement the class in such awy that same player can not call makeMove twice simultaneously.
see the example.
class Move {};
class Player {
void makeMove(Move *m) {
}
};
// situation 1:
Player p1;
p1.makeMove(new move());
p1.makeMove(new move()); // it should give error
// situation 2:
Player p1;
p1.makeMove(new move());
Player p2;
p2.makeMove(new move());
p1.makeMove(new move()); // it os ok
Please help me in designing the classes
First of all, I don’t think that Player class should be responsible for that. It would be better of with something like
In which
ChessEnginecould have a list of previous moves and then check if player is allowed to move.