From 253e1cf42323163e0ab4bcd77619cdf7179afeab Mon Sep 17 00:00:00 2001 From: ParkSuMin Date: Mon, 7 Jul 2025 02:43:47 +0300 Subject: [PATCH] Delete Soldier class Make Infantry as structure --- CMakeLists.txt | 6 +++++- include/Infantry.h | 15 +++------------ include/Player.h | 4 ++-- include/Soldier.h | 14 -------------- include/stdafx.h | 1 - src/Infantry.cpp | 6 ++++++ 6 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 include/Soldier.h create mode 100644 src/Infantry.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f04b73..b313a08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,11 +16,15 @@ if (POLICY CMP0141) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$,$>,$<$:EditAndContinue>,$<$:ProgramDatabase>>") endif() +include_directories(include) project ("BattleCap") include_directories(include) # Добавьте источник в исполняемый файл этого проекта. -add_executable (BattleCap "src/BattleCap.cpp" "include/BattleCap.h" "include/Soldier.h" "include/Game.h" "include/Infantry.h" "src/Game.cpp" "include/Player.h" "include/stdafx.h") +add_executable (BattleCap +"src/BattleCap.cpp" +"src/Game.cpp" +"src/Infantry.cpp") if (CMAKE_VERSION VERSION_GREATER 3.12) set_property(TARGET BattleCap PROPERTY CXX_STANDARD 20) diff --git a/include/Infantry.h b/include/Infantry.h index b903148..c5da856 100644 --- a/include/Infantry.h +++ b/include/Infantry.h @@ -1,14 +1,5 @@ #pragma once -#include "Soldier.h" -class Infantry : public Soldier { -public: - Infantry() : Soldier() {}; - int step() override - { - return 10; - } - void fire() override - { - return; - } + +struct Infantry { + void attack(); }; \ No newline at end of file diff --git a/include/Player.h b/include/Player.h index bfc5539..81dbc80 100644 --- a/include/Player.h +++ b/include/Player.h @@ -6,7 +6,7 @@ class Player { private: char name; - std::vector> army; + std::vector> army; double score; public: Player() { @@ -15,7 +15,7 @@ public: army.push_back(std::make_unique()); } } - std::vector>& get_army() { + std::vector>& get_army() { return army; } }; \ No newline at end of file diff --git a/include/Soldier.h b/include/Soldier.h deleted file mode 100644 index d216cf3..0000000 --- a/include/Soldier.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -class Soldier { -private: - double HP; - double attack; - double defence; - char type; -protected: - Soldier() : HP(100), attack(1), defence(1) {}; - Soldier(double _HP, double _attack, double _defence) : HP(_HP), attack(_attack), defence(_defence) {}; -public: - virtual int step() = 0; - virtual void fire() = 0; -}; \ No newline at end of file diff --git a/include/stdafx.h b/include/stdafx.h index 9748995..598255c 100644 --- a/include/stdafx.h +++ b/include/stdafx.h @@ -8,7 +8,6 @@ #include "curses.h" #endif // WINDOWS -#include "Soldier.h" #include "Infantry.h" #include "Game.h" #include "Player.h" diff --git a/src/Infantry.cpp b/src/Infantry.cpp new file mode 100644 index 0000000..9ccf98b --- /dev/null +++ b/src/Infantry.cpp @@ -0,0 +1,6 @@ +#include "Infantry.h" + +void Infantry::attack() +{ + return; +}