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/Rook.hpp | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 DiamondProblemAndPolymorphism/Chess/Rook.hpp (limited to 'DiamondProblemAndPolymorphism/Chess/Rook.hpp') diff --git a/DiamondProblemAndPolymorphism/Chess/Rook.hpp b/DiamondProblemAndPolymorphism/Chess/Rook.hpp new file mode 100644 index 0000000..576920a --- /dev/null +++ b/DiamondProblemAndPolymorphism/Chess/Rook.hpp @@ -0,0 +1,30 @@ +#include "Figure.hpp" + +class Rook : virtual public Figure +{ + +public: + Rook(int xCoordinate, int yCoordinate, bool isWhite) :Figure(xCoordinate, yCoordinate, isWhite) + {} + + bool Move(int xNew, int yNew); + + void Print(); + +}; + +bool Rook::Move(int xNew, int yNew); +{ + if (!isValidCoord(xNew, yNew)) + return false; + if (!(xCoord == xNew ^ yCoord == yNew)) + return false; + xCoord = xNew; + yCoord = yNew; + return true; +} + +void Rook::Print() +{ + cout << 'R'; +} \ No newline at end of file -- cgit v1.3.1-23-gd82d