12345678910111213141516171819202122232425262728293031323334353637 |
- #include "Pawn.h"
- #include "Position.h"
- #include <utility>
- #include <stdexcept>
- #include <iostream>
- Pawn::Pawn(Position pos, char c) {
- if (c != 'B' and c != 'W')
- throw std::invalid_argument("Impossible color of figure!");
- position = pos;
- color = c;
- }
- std::pair<int, Position*> Pawn::get_moves()
- {
- Position* moves = new Position[1];
- Position p;
- try {
- p = Position(position.posSym, (char)(position.posNum+1));
- }
- catch (const std::invalid_argument) {
- p = Position();
- }
- moves[0] = p;
- return std::pair<int, Position*>(1, moves);
- }
- const char* Pawn::print()
- {
- const char* me;
- if (color == 'B')
- me = "♟";
- else
- me = "♙";
- return me;
- }
|