Skip to content
Snippets Groups Projects
Commit 99d269e8 authored by Giann Karlo Aguirre Samboní's avatar Giann Karlo Aguirre Samboní
Browse files

printable node types

parent ebd72bf3
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
}
#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
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment