Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 15 / Chess / Figures / Rook
diff options
context:
space:
mode:
Commit50444e86ea5048e05b8eb74055e0f7c4d2c5d7b7 (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2021-06-10 18:54:25 +0300
Committer
 angeld55 <angel_dimitriev@abv.bg>
2021-06-10 18:54:25 +0300
Files098cf947bc45b4b747d3da5259fc8044c5724d8b /Sem. 15/Chess/Figures/Rook
Object-oriented_programming_FMI-50444e86ea5048e05b8eb74055e0f7c4d2c5d7b7.tar
Object-oriented_programming_FMI-50444e86ea5048e05b8eb74055e0f7c4d2c5d7b7.tar.gz
Object-oriented_programming_FMI-50444e86ea5048e05b8eb74055e0f7c4d2c5d7b7.zip
Parentd1e6ffd0fef9ebc7a8baae5e0b75b468ad8ed11a (diff)
sem 15
2 files changed, 26 insertions, 0 deletions
-rw-r--r--Sem. 15/Chess/Figures/Rook/Rook.cpp15
-rw-r--r--Sem. 15/Chess/Figures/Rook/Rook.h11
diff --git a/Sem. 15/Chess/Figures/Rook/Rook.cpp b/Sem. 15/Chess/Figures/Rook/Rook.cpp
new file mode 100644
index 0000000..19e84a6
--- /dev/null
+++ b/Sem. 15/Chess/Figures/Rook/Rook.cpp
@@ -0,0 +1,15 @@
+#include "Rook.h"
+
+Rook::Rook(bool isWhite) : Figure(isWhite)
+{}
+bool Rook::canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const
+{
+ return currentX == destX || currentY == destY;
+}
+void Rook::print() const
+{
+ if (getIsWhite())
+ std::cout << 'R';
+ else
+ std::cout << 'r';
+}
diff --git a/Sem. 15/Chess/Figures/Rook/Rook.h b/Sem. 15/Chess/Figures/Rook/Rook.h
new file mode 100644
index 0000000..f6190a8
--- /dev/null
+++ b/Sem. 15/Chess/Figures/Rook/Rook.h
@@ -0,0 +1,11 @@
+#pragma once
+#include "../FigureBase/Figure.h"
+
+class Rook : virtual public Figure
+{
+
+public:
+ Rook(bool isWhite);
+ bool canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const override;
+ void print() const override;
+}; \ No newline at end of file