|
@@ -1,15 +1,17 @@
|
|
#include "Position.h"
|
|
#include "Position.h"
|
|
|
|
+#include <stdexcept>
|
|
|
|
+#include <iostream>
|
|
|
|
|
|
Position::Position()
|
|
Position::Position()
|
|
{
|
|
{
|
|
posSym = '0';
|
|
posSym = '0';
|
|
- posSym = '0';
|
|
|
|
|
|
+ posNum = '0';
|
|
}
|
|
}
|
|
|
|
|
|
Position::Position(char posS, char posN)
|
|
Position::Position(char posS, char posN)
|
|
{
|
|
{
|
|
if (posS > 'H' or posN > '8' or posS < 'A' or posN < '1')
|
|
if (posS > 'H' or posN > '8' or posS < 'A' or posN < '1')
|
|
- throw "Impossible move";
|
|
|
|
|
|
+ throw std::invalid_argument("Impossible move");
|
|
posSym = posS;
|
|
posSym = posS;
|
|
posNum = posN;
|
|
posNum = posN;
|
|
}
|
|
}
|
|
@@ -17,7 +19,13 @@ Position::Position(char posS, char posN)
|
|
Position::Position(char posS, int posN)
|
|
Position::Position(char posS, int posN)
|
|
{
|
|
{
|
|
if (posS > 'H' or posN > '8' or posS < 'A' or posN < '1')
|
|
if (posS > 'H' or posN > '8' or posS < 'A' or posN < '1')
|
|
- throw "Impossible move";
|
|
|
|
|
|
+ throw std::invalid_argument("Impossible move");
|
|
posNum = '0' + posN;
|
|
posNum = '0' + posN;
|
|
posSym = posS;
|
|
posSym = posS;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+std::ostream& operator <<(std::ostream& out, Position& p)
|
|
|
|
+{
|
|
|
|
+ out << p.posSym << p.posNum;
|
|
|
|
+ return out;
|
|
}
|
|
}
|