1234567891011121314151617181920212223242526272829303132333435 |
- #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;
- }
- vector<Position> Pawn::get_moves()
- {
- vector<Position> moves;
- Position p;
- try {
- p = Position(position.posSym, (char)(position.posNum+1));
- }
- catch (const std::invalid_argument) {}
- moves.push_back(p);
- return moves;
- }
- const char* Pawn::print()
- {
- const char* me;
- if (color == 'B')
- me = "♟";
- else
- me = "♙";
- return me;
- }
|