diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 64d53c1cc6c0e4115ee2af9aea1a3c335d60d5d6..88de2d69995cb10a9783d7d71e7a5912f1cdb497 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.0.0) project(adt2amas_exec CXX) # Libraries -add_library(adt_libs ad_tree.cpp tree_node.cpp node_type.hpp) +add_library(adt_libs ad_tree.cpp tree_node.cpp node_type.cpp) target_include_directories(adt_libs PUBLIC ${CMAKE_CURRENT_LIST_DIR}) # The main programn diff --git a/src/adt2amas.cpp b/src/adt2amas.cpp index 023e053a7022246e0a44555cd016ba2df382a54d..47bf3e93b8c09d469080df5bed36399c2e2ec2ad 100644 --- a/src/adt2amas.cpp +++ b/src/adt2amas.cpp @@ -41,8 +41,9 @@ int main(){ // Removing... //node_one->remove_child(node_six, node_one); node_one->remove_parent_pos(0, node_six); - node_one->remove_child_pos(0, node_ten); + // node_one->remove_child_pos(0, node_ten); + // Lineage printing... cout << "child associated ids of node one:" << endl; for (auto& i : node_one->get_child_associated_ids()) // reference to The C++ Programming Language book, p. 899 cout << i << ' '; @@ -68,7 +69,8 @@ int main(){ delete tree; - NodeType nodeTest{NodeType::Defence}; - cout << "node type = " << static_cast<int>(nodeTest) << endl; + NodeType nodeTest{NodeType::Attack}; + cout << "node type = " << to_string(nodeTest) << endl; + } diff --git a/src/node_type.cpp b/src/node_type.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b34514ab00562b6234d1918d12eb9f8ac6556587 --- /dev/null +++ b/src/node_type.cpp @@ -0,0 +1,18 @@ +#include "node_type.hpp" + +string to_string(NodeType nt){ + + string _nt = ""; + switch (nt) + { + case NodeType::Defence : + _nt = "Defence"; + break; + case NodeType::Attack : + _nt = "Attack"; + default: + break; + } + + return _nt; +} \ No newline at end of file diff --git a/src/node_type.hpp b/src/node_type.hpp index 79db26576ee4f4886d88d0779c5c37dc96e0d539..f4a0797ded2974b96b659106af17786d7ca0ed37 100644 --- a/src/node_type.hpp +++ b/src/node_type.hpp @@ -2,6 +2,7 @@ #define NODE_TYPE_HPP #include <iostream> +#include <string> using namespace std; @@ -10,4 +11,7 @@ enum class NodeType Defence, // 0 Attack // 1 }; + +string to_string(NodeType nt); + #endif