From e82491b4c5331dcd854a446df01a9c76c0e50369 Mon Sep 17 00:00:00 2001 From: Angeld55 Date: Sat, 21 Sep 2019 12:08:32 +0300 Subject: Add files via upload --- DiamondProblemAndPolymorphism/Chess/Figure.hpp | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 DiamondProblemAndPolymorphism/Chess/Figure.hpp (limited to 'DiamondProblemAndPolymorphism/Chess/Figure.hpp') diff --git a/DiamondProblemAndPolymorphism/Chess/Figure.hpp b/DiamondProblemAndPolymorphism/Chess/Figure.hpp new file mode 100644 index 0000000..157659b --- /dev/null +++ b/DiamondProblemAndPolymorphism/Chess/Figure.hpp @@ -0,0 +1,34 @@ +#include + +using namespace std; + +bool isValidCoord(int xCoord, int yCoord) +{ + return xCoord >= 0 && xCoord <= 7 + && yCoord >= 0 && yCoord <= 7; +} + +class Figure +{ +public: + Figure(int xCoord, int yCoord, bool isWhite); + + int xCoord; + int yCoord; + bool isWhite; + virtual bool Move(int xCoord, int yCoord) = 0; + virtual void Print() = 0; + virtual ~Figure(){}; +}; + +Figure::Figure(int xCoord, int yCoord, bool isWhite); +{ + if (isValidCoord(xCoord, yCoord)) + { + this->xCoord = xCoord; + this->yCoord = yCoord; + this->isWhite = isWhite; + } + else + throw "Ivalid coordinates"; +} \ No newline at end of file -- cgit v1.3.1-23-gd82d