summaryrefslogtreecommitdiff
path: root/Gate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Gate.cpp')
-rw-r--r--Gate.cpp67
1 files changed, 65 insertions, 2 deletions
diff --git a/Gate.cpp b/Gate.cpp
index 4a789c3..9ffa50d 100644
--- a/Gate.cpp
+++ b/Gate.cpp
@@ -22,7 +22,7 @@ Gate::Gate(GATE_TYPE type, int x, int y, int width, int height)
this->gate_type = type;
this->input_gate1 = nullptr;
this->input_gate2 = nullptr;
- this->output_gate = nullptr;
+ //this->output_gate = nullptr;
this->id = Gate::gate_id_counter++; // increment counter after assigning
this->x = x;
this->y = y;
@@ -56,7 +56,6 @@ void Gate::update_state()
break;
}
-
case AND:
{
if (!input_gate1 || !input_gate2) {this->output_state = false; return; }
@@ -117,3 +116,67 @@ void Gate::update_state()
break;
}
}
+std::string
+Gate::get_output_type_text()
+{
+ std::string out;
+ switch (this->gate_type)
+ {
+ case INPUT:
+ {
+ return "INPUT";
+ }
+
+ case OUTPUT:
+ {
+ return "OUTPUT";
+ }
+
+ case AND:
+ {
+ return "AND";
+ }
+
+
+ case OR:
+ {
+ return "OR";
+ }
+
+
+ case NOT:
+ {
+ return "NOT";
+ }
+
+
+ case NAND:
+ {
+ return "NAND";
+ }
+
+
+ case NOR:
+ {
+ return "NOR";
+ }
+
+
+ case XOR:
+ {
+ return "XOR";
+ }
+
+
+ case XNOR:
+ {
+ return "XNOR";
+ }
+
+ default:
+ return "?";
+ }
+
+}
+
+