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

gates added but not ended

parent 4375d4d6
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.cpp)
add_library(adt_libs ad_tree.cpp and.cpp gate.cpp nand.cpp node_type.cpp nor.cpp or.cpp sand.cpp snand.cpp snor.cpp sor.cpp tree_node.cpp)
target_include_directories(adt_libs PUBLIC ${CMAKE_CURRENT_LIST_DIR})
# The main programn
......
#include "ad_tree.hpp"
#include "gate.hpp"
#include "and.hpp"
#include "or.hpp"
#include "sand.hpp"
#include "sor.hpp"
#include "nand.hpp"
#include "nor.hpp"
#include "snand.hpp"
#include "snor.hpp"
int main(){
......@@ -12,6 +21,14 @@ int main(){
TreeNode* node_seven = new TreeNode();
TreeNode* node_eight = new TreeNode();
TreeNode* node_nine = new TreeNode();
And* node_ten = new And();
Or* node_eleven = new Or();
Sand* node_twelve = new Sand();
Sor* node_thirdteen = new Sor();
Nand* node_fourteen = new Nand();
Nor* node_fiveteen = new Nor();
Snand* node_sixteen = new Snand();
Snor* node_seventeen = new Snor();
//ADtree tree;
ADtree *tree = new ADtree(node_zero);
......@@ -57,22 +74,21 @@ int main(){
tree->remove_child(node_six, node_zero);
tree->remove_child(node_seven, node_zero); */
tree->remove_parent_pos(0, node_five);
/* tree->remove_parent_pos(0, node_five);
tree->remove_parent_pos(2, node_five);
tree->remove_parent_pos(1, node_five);
tree->remove_parent_pos(0, node_five);
/* tree->remove_parent(node_zero, node_one);
tree->remove_parent_pos(0, node_five); */
tree->remove_parent(node_zero, node_one);
tree->remove_parent(node_zero, node_two);
tree->remove_parent(node_zero, node_three);
tree->remove_parent(node_zero, node_four);
tree->remove_parent(node_zero, node_five);
tree->remove_parent(node_zero, node_six);
tree->remove_parent(node_zero, node_seven); */
tree->remove_parent(node_zero, node_seven);
//tree->remove_child_pos(0, node_nine);
cout << tree->get_info();
cout << tree->ids_in_tree() << endl;
cout << node_five->get_info() << endl;
// Lineage printing...
/* cout << "child associated ids of node one:" << endl;
......@@ -83,9 +99,16 @@ int main(){
for(auto it = (tmp_set).cbegin() ; it != (tmp_set).cend() && *it != cur_child->get_id(); it++){
std::cout << *it << ' ';
} */
tree->add_child(node_ten, node_zero);
delete tree;
cout << node_ten->get_info() << endl;
cout << node_eleven->get_info() << endl;
cout << node_twelve->get_info() << endl;
cout << node_thirdteen->get_info() << endl;
cout << node_fourteen->get_info() << endl;
cout << node_fiveteen->get_info() << endl;
cout << node_sixteen->get_info() << endl;
cout << node_seventeen->get_info() << endl;
/* NodeType nodeTest{NodeType::Attack};
cout << "node type = " << to_string(nodeTest) << endl; */
return 0;
......
#include "and.hpp"
And::And() { }
And::~And() { }
string And::get_info (){
return "And" + TreeNode::get_info();
}
\ No newline at end of file
#ifndef AND_HPP
#define AND_HPP
#include "gate.hpp"
class And : public Gate
{
private:
/* data */
public:
And();
~And();
string get_info ();
};
#endif
\ No newline at end of file
#include "gate.hpp"
Gate::Gate() { }
Gate::~Gate() { }
\ No newline at end of file
#ifndef GATE_HPP
#define GATE_HPP
#include "tree_node.hpp"
class Gate : public TreeNode
{
private:
/* data */
public:
Gate();
~Gate();
/*Others methods*/
virtual string get_info () = 0;
};
#endif
\ No newline at end of file
#include "nand.hpp"
Nand::Nand() { }
Nand::~Nand() { }
string Nand::get_info (){
return "Nand" + TreeNode::get_info();
}
\ No newline at end of file
#ifndef NAND_HPP
#define NAND_HPP
#include "gate.hpp"
class Nand : public Gate
{
private:
/* data */
public:
Nand();
~Nand();
string get_info ();
};
#endif
\ No newline at end of file
#include "nor.hpp"
Nor::Nor() { }
Nor::~Nor() { }
string Nor::get_info (){
return "Nor" + TreeNode::get_info();
}
\ No newline at end of file
#ifndef NOR_HPP
#define NOR_HPP
#include "gate.hpp"
class Nor : public Gate
{
private:
/* data */
public:
Nor();
~Nor();
string get_info ();
};
#endif
\ No newline at end of file
#include "or.hpp"
Or::Or() { }
Or::~Or() { }
string Or::get_info (){
return "Or" + TreeNode::get_info();
}
\ No newline at end of file
#ifndef OR_HPP
#define OR_HPP
#include "gate.hpp"
class Or : public Gate
{
private:
/* data */
public:
Or();
~Or();
string get_info ();
};
#endif
\ No newline at end of file
#include "sand.hpp"
Sand::Sand() { }
Sand::~Sand() { }
string Sand::get_info (){
return "Sand" + TreeNode::get_info();
}
\ No newline at end of file
#ifndef SAND_HPP
#define SAND_HPP
#include "gate.hpp"
class Sand : public Gate
{
private:
/* data */
public:
Sand();
~Sand();
string get_info ();
};
#endif
\ No newline at end of file
#include "snand.hpp"
Snand::Snand() { }
Snand::~Snand() { }
string Snand::get_info (){
return "Snand" + TreeNode::get_info();
}
\ No newline at end of file
#ifndef SNAND_HPP
#define SNAND_HPP
#include "gate.hpp"
class Snand : public Gate
{
private:
/* data */
public:
Snand();
~Snand();
string get_info ();
};
#endif
\ No newline at end of file
#include "snor.hpp"
Snor::Snor() { }
Snor::~Snor() { }
string Snor::get_info (){
return "Snor" + TreeNode::get_info();
}
\ No newline at end of file
#ifndef SNOR_HPP
#define SNOR_HPP
#include "gate.hpp"
class Snor : public Gate
{
private:
/* data */
public:
Snor();
~Snor();
string get_info ();
};
#endif
\ No newline at end of file
#include "sor.hpp"
Sor::Sor() { }
Sor::~Sor() { }
string Sor::get_info (){
return "Sor" + TreeNode::get_info();
}
\ No newline at end of file
#ifndef SOR_HPP
#define SOR_HPP
#include "gate.hpp"
class Sor : public Gate
{
private:
/* data */
public:
Sor();
~Sor();
string get_info ();
};
#endif
\ No newline at end of file
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