CheckerPosition.cpp 438 B

1234567891011121314151617
  1. #include "CheckerPosition.h"
  2. #include "CheckerConsts.h"
  3. CheckerPosition::CheckerPosition(int x, int y) : x(x), y(y) {}
  4. CheckerPosition::CheckerPosition(std::string pos) {
  5. x = pos[0] - 'A';
  6. y = pos[1] - '1';
  7. }
  8. std::string CheckerPosition::to_string() const {
  9. return std::string(1, 'A' + x) + std::to_string(y + 1);
  10. }
  11. bool CheckerPosition::isValid() const {
  12. return x >= 0 && x < BOARD_SIZE && y >= 0 && y < BOARD_SIZE;
  13. }