Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 15
diff options
context:
space:
mode:
Commit8cf1283a4ffb9fe1901c29c087fa376de82726af (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2022-02-19 23:30:52 +0200
Committer
 angeld55 <angel_dimitriev@abv.bg>
2022-02-19 23:30:52 +0200
Filesabdfe6bf526100dcce87a88563100e02adf7605e /Sem. 15
Object-oriented_programming_FMI-8cf1283a4ffb9fe1901c29c087fa376de82726af.tar
Object-oriented_programming_FMI-8cf1283a4ffb9fe1901c29c087fa376de82726af.tar.gz
Object-oriented_programming_FMI-8cf1283a4ffb9fe1901c29c087fa376de82726af.zip
Parentd73a7ec225516657dec74472a0491330e9999217 (diff)
clean up
diff --git a/Sem. 15/Chess_basic_prototype/ChessBoard/ChessBoard.cpp b/Sem. 15/Chess_basic_prototype/ChessBoard/ChessBoard.cpp
deleted file mode 100644
index ed9823d..0000000
--- a/Sem. 15/Chess_basic_prototype/ChessBoard/ChessBoard.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-#include "ChessBoard.h"
-#include "../FigureFactory/FigureFactory.h"
-
-ChessBoard::ChessBoard()
-{
-
- for (int i = 0; i < BOARD_SIZE; i++)
- {
- board[1][i].f = FigureFactory::createFigure(false, PawnFigure);
- board[6][i].f = FigureFactory::createFigure(true, PawnFigure);
- }
-
- board[0][0].f = FigureFactory::createFigure(false, RookFigure);
- board[0][7].f = FigureFactory::createFigure(false, RookFigure);
-
- board[7][0].f = FigureFactory::createFigure(true, RookFigure);
- board[7][7].f = FigureFactory::createFigure(true, RookFigure);
-
-
- board[0][1].f = FigureFactory::createFigure(false, KnightFigure);
- board[0][6].f = FigureFactory::createFigure(false, KnightFigure);
- board[7][1].f = FigureFactory::createFigure(true, KnightFigure);;
- board[7][6].f = FigureFactory::createFigure(true, KnightFigure);
-
- board[0][2].f = FigureFactory::createFigure(false, BishopFigure);
- board[0][5].f = FigureFactory::createFigure(false, BishopFigure);;
- board[7][2].f = FigureFactory::createFigure(true, BishopFigure);
- board[7][5].f = FigureFactory::createFigure(true, BishopFigure);
-
- board[0][3].f = FigureFactory::createFigure(false, KingFigure);
- board[0][4].f = FigureFactory::createFigure(false, QueenFigure);
- board[7][4].f = FigureFactory::createFigure(true, QueenFigure);
- board[7][3].f = FigureFactory::createFigure(true, KingFigure);
-}
-
-void ChessBoard::print() const
-{
- std::cout << "--------" << std::endl;
- for (int i = 0; i < BOARD_SIZE; i++)
- {
- for (int j = 0; j < BOARD_SIZE; j++)
- {
- board[i][j].print();
- }
- std::cout << std::endl;
- }
- std::cout << "--------" << std::endl << std::endl << std::endl;
-}
-
-void ChessBoard::moveFigure(size_t x, size_t y, size_t destX, size_t destY)
-{
-
- Figure* current = board[x][y].f;
-
- if (current->getType() == PawnFigure)
- {
- //Some other logic..... El'passant and other
- }
- else
- {
- if (board[x][y].f && board[x][y].f->canBeMoved(x, y, destX, destY))
- {
- delete board[destX][destY].f;
- board[destX][destY].f = board[x][y].f;
- board[x][y].f = nullptr;
- }
- }
-
-} \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/ChessBoard/ChessBoard.h b/Sem. 15/Chess_basic_prototype/ChessBoard/ChessBoard.h
deleted file mode 100644
index 315e492..0000000
--- a/Sem. 15/Chess_basic_prototype/ChessBoard/ChessBoard.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#pragma once
-#include "../Figures/FigureBase/Figure.h"
-
-const size_t BOARD_SIZE = 8;
-class ChessBoard
-{
- struct Cell
- {
- Figure* f = nullptr;
- Cell() = default;
-
- Cell(const Cell& other) = delete;
- Cell& operator=(const Cell& other) = delete;
- bool isEmpty()
- {
- return f == nullptr;
- }
-
- void print() const
- {
- if (f != nullptr)
- f->print();
- else
- std::cout << ' ';
- }
-
- ~Cell()
- {
- delete f;
- }
- };
- Cell board[BOARD_SIZE][BOARD_SIZE];
-
-public:
- ChessBoard();
- ChessBoard(const ChessBoard& other) = delete;
- ChessBoard& operator=(const ChessBoard&) = delete;
-
- void print() const;
-
- void moveFigure(size_t x, size_t y, size_t destX, size_t destY);
-
-};
diff --git a/Sem. 15/Chess_basic_prototype/ConfigEnums/ConfigEnums.h b/Sem. 15/Chess_basic_prototype/ConfigEnums/ConfigEnums.h
deleted file mode 100644
index c3448e8..0000000
--- a/Sem. 15/Chess_basic_prototype/ConfigEnums/ConfigEnums.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-
-enum FigureType
-{
- KingFigure,
- QueenFigure,
- KnightFigure,
- BishopFigure,
- PawnFigure,
- RookFigure
-}; \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/FigureFactory/FigureFactory.cpp b/Sem. 15/Chess_basic_prototype/FigureFactory/FigureFactory.cpp
deleted file mode 100644
index e9db605..0000000
--- a/Sem. 15/Chess_basic_prototype/FigureFactory/FigureFactory.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "FigureFactory.h"
-#include "../Figures/Bishop/Bishop.h"
-#include "../Figures/King/King.h"
-#include "../Figures/Knight/Knight.h"
-#include "../Figures/Rook/Rook.h"
-#include "../Figures/Queen/Queen.h"
-#include "../Figures/Pawn/Pawn.h"
-
-Figure* FigureFactory::createFigure(bool isWhite, FigureType type)
-{
-
- switch (type)
- {
- case KingFigure:
- return new King(isWhite);
- case QueenFigure:
- return new Queen(isWhite);
- case KnightFigure:
- return new Knight(isWhite);
- case BishopFigure:
- return new Bishop(isWhite);
- case PawnFigure:
- return new Pawn(isWhite);
- case RookFigure:
- return new Rook(isWhite);
- }
-} \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/FigureFactory/FigureFactory.h b/Sem. 15/Chess_basic_prototype/FigureFactory/FigureFactory.h
deleted file mode 100644
index 012a60c..0000000
--- a/Sem. 15/Chess_basic_prototype/FigureFactory/FigureFactory.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma once
-#include "../Figures/FigureBase/Figure.h"
-#include "../ConfigEnums/ConfigEnums.h"
-
-class FigureFactory
-{
-public:
- static Figure* createFigure(bool isWhite, FigureType); //enum
-}; \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/Figures/Bishop/Bishop.cpp b/Sem. 15/Chess_basic_prototype/Figures/Bishop/Bishop.cpp
deleted file mode 100644
index 786c9eb..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Bishop/Bishop.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "Bishop.h"
-#include <cmath>
-
-Bishop::Bishop(bool isWhite) : Figure(isWhite, RookFigure)
-{}
-bool Bishop::canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const
-{
- return abs((int)currentX - (int)destX) == abs((int)currentY - (int)destY);
-}
-void Bishop::print() const
-{
- if (getIsWhite())
- std::cout << 'B';
- else
- std::cout << 'b';
-}
diff --git a/Sem. 15/Chess_basic_prototype/Figures/Bishop/Bishop.h b/Sem. 15/Chess_basic_prototype/Figures/Bishop/Bishop.h
deleted file mode 100644
index 86949a7..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Bishop/Bishop.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-#include "../FigureBase/Figure.h"
-
-class Bishop : virtual public Figure
-{
-
-public:
- Bishop(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
diff --git a/Sem. 15/Chess_basic_prototype/Figures/FigureBase/Figure.cpp b/Sem. 15/Chess_basic_prototype/Figures/FigureBase/Figure.cpp
deleted file mode 100644
index e69de29..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/FigureBase/Figure.cpp
+++ /dev/null
diff --git a/Sem. 15/Chess_basic_prototype/Figures/FigureBase/Figure.h b/Sem. 15/Chess_basic_prototype/Figures/FigureBase/Figure.h
deleted file mode 100644
index 9e2300a..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/FigureBase/Figure.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-#include <iostream>
-#include "../../ConfigEnums/ConfigEnums.h"
-
-class Figure
-{
- bool isWhite;
- FigureType type;
-
-public:
- Figure(bool isWhite, FigureType type) :isWhite(isWhite), type(type)
- {}
-
- virtual bool canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const = 0;
- virtual void print() const = 0;
-
- bool getIsWhite() const { return isWhite; };
- FigureType getType() const { return type; }
-
- virtual ~Figure(){};
-}; \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/Figures/King/King.cpp b/Sem. 15/Chess_basic_prototype/Figures/King/King.cpp
deleted file mode 100644
index 8ca67e8..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/King/King.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "King.h"
-#include <cmath>
-
-King::King(bool isWhite) : Figure(isWhite, KingFigure)
-{}
-bool King::canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const
-{
- return abs((int)currentX - (int)destX) <= 1 && abs((int)currentY - (int)destY) <= 1;
-}
-void King::print() const
-{
- if (getIsWhite())
- std::cout << '%';
- else
- std::cout << '$';
-} \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/Figures/King/King.h b/Sem. 15/Chess_basic_prototype/Figures/King/King.h
deleted file mode 100644
index 85a8e02..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/King/King.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-#include "../FigureBase/Figure.h"
-
-class King : public Figure
-{
-
-public:
- King(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
diff --git a/Sem. 15/Chess_basic_prototype/Figures/Knight/Knight.cpp b/Sem. 15/Chess_basic_prototype/Figures/Knight/Knight.cpp
deleted file mode 100644
index 5713d7c..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Knight/Knight.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "Knight.h"
-#include <cmath>
-
-Knight::Knight(bool isWhite) : Figure(isWhite, KnightFigure)
-{}
-bool Knight::canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const
-{
- int xMovеment[] = { 1, 1, -1, -1, 2, -2, 2, -2 };
- int yMovеment[] = { 2, -2, 2, -2, 1, 1, -1, -1 };
-
- for (int i = 0; i < 8; i++)
- {
- if (currentX + xMovеment[i] == destX &&
- currentY + yMovеment[i] == destY)
- return true;
- }
- return false;
-}
-
-void Knight::print() const
-{
- if (getIsWhite())
- std::cout << 'K';
- else
- std::cout << 'k';
-} \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/Figures/Knight/Knight.h b/Sem. 15/Chess_basic_prototype/Figures/Knight/Knight.h
deleted file mode 100644
index 72acfea..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Knight/Knight.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-#include "../FigureBase/Figure.h"
-
-class Knight : public Figure
-{
-
-public:
- Knight(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
diff --git a/Sem. 15/Chess_basic_prototype/Figures/Pawn/Pawn.cpp b/Sem. 15/Chess_basic_prototype/Figures/Pawn/Pawn.cpp
deleted file mode 100644
index 347032b..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Pawn/Pawn.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "Pawn.h"
-#include <cmath>
-Pawn::Pawn(bool isWhite) : Figure(isWhite, PawnFigure), isFirstMove(true)
-{}
-
-bool Pawn::canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const
-{
- if (getIsWhite())
- return currentY - 1 == destY && abs((int)currentX - (int)destX) <= 1;
- else
- return currentY + 1 == destY && abs((int)currentX - (int)destX) <= 1;
-}
-
-void Pawn::print() const
-{
- if (getIsWhite())
- std::cout << 'P';
- else
- std::cout << 'p';
-} \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/Figures/Pawn/Pawn.h b/Sem. 15/Chess_basic_prototype/Figures/Pawn/Pawn.h
deleted file mode 100644
index 675bf0b..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Pawn/Pawn.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-#include "../FigureBase/Figure.h"
-
-class Pawn : virtual public Figure
-{
- bool isFirstMove;
-public:
- Pawn(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
diff --git a/Sem. 15/Chess_basic_prototype/Figures/Queen/Queen.cpp b/Sem. 15/Chess_basic_prototype/Figures/Queen/Queen.cpp
deleted file mode 100644
index 0e33198..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Queen/Queen.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "Queen.h"
-
-Queen::Queen(bool isWhite) : Bishop(isWhite), Rook(isWhite), Figure(isWhite, QueenFigure)
-{}
-
-bool Queen::canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const
-{
- return Bishop::canBeMoved(currentX, currentY, destX, destY)
- || Rook::canBeMoved(currentX, currentY, destX, destY);
-}
-
-void Queen::print() const
-{
- if (getIsWhite())
- std::cout << 'Q';
- else
- std::cout << 'q';
-} \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/Figures/Queen/Queen.h b/Sem. 15/Chess_basic_prototype/Figures/Queen/Queen.h
deleted file mode 100644
index c4fb1da..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Queen/Queen.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-#include "../Bishop/Bishop.h"
-#include "../Rook/Rook.h"
-
-class Queen : public Bishop, public Rook
-{
-public:
- Queen(bool isWhite);
- bool canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const;
- void print() const;
-}; \ No newline at end of file
diff --git a/Sem. 15/Chess_basic_prototype/Figures/Rook/Rook.cpp b/Sem. 15/Chess_basic_prototype/Figures/Rook/Rook.cpp
deleted file mode 100644
index 2cb96a3..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Rook/Rook.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "Rook.h"
-
-Rook::Rook(bool isWhite) : Figure(isWhite, RookFigure)
-{}
-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_basic_prototype/Figures/Rook/Rook.h b/Sem. 15/Chess_basic_prototype/Figures/Rook/Rook.h
deleted file mode 100644
index f6190a8..0000000
--- a/Sem. 15/Chess_basic_prototype/Figures/Rook/Rook.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#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
diff --git a/Sem. 15/Chess_basic_prototype/main.cpp b/Sem. 15/Chess_basic_prototype/main.cpp
deleted file mode 100644
index 6673ec8..0000000
--- a/Sem. 15/Chess_basic_prototype/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <iostream>
-#include "ChessBoard/ChessBoard.h"
-using namespace std;
-
-//ШАХ
-
-int main()
-{
- ChessBoard c;
-
- c.print();
-
- c.moveFigure(0, 1, 2, 0);
-
- c.print();
-} \ No newline at end of file
diff --git a/Sem. 15/README.md b/Sem. 15/README.md
deleted file mode 100644
index 8a445d4..0000000
--- a/Sem. 15/README.md
+++ /dev/null
@@ -1 +0,0 @@
-TBD