Delete Soldier class
Make Infantry as structure
This commit is contained in:
@@ -16,11 +16,15 @@ if (POLICY CMP0141)
|
||||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>: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)
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
@@ -6,7 +6,7 @@
|
||||
class Player {
|
||||
private:
|
||||
char name;
|
||||
std::vector<std::unique_ptr<Soldier>> army;
|
||||
std::vector<std::unique_ptr<Infantry>> army;
|
||||
double score;
|
||||
public:
|
||||
Player() {
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
army.push_back(std::make_unique<Infantry>());
|
||||
}
|
||||
}
|
||||
std::vector<std::unique_ptr<Soldier>>& get_army() {
|
||||
std::vector<std::unique_ptr<Infantry>>& get_army() {
|
||||
return army;
|
||||
}
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "curses.h"
|
||||
#endif // WINDOWS
|
||||
|
||||
#include "Soldier.h"
|
||||
#include "Infantry.h"
|
||||
#include "Game.h"
|
||||
#include "Player.h"
|
||||
|
||||
6
src/Infantry.cpp
Normal file
6
src/Infantry.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "Infantry.h"
|
||||
|
||||
void Infantry::attack()
|
||||
{
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user