summaryrefslogtreecommitdiff
path: root/Gate.cpp
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-06-24 11:21:58 +0930
committerDaniel Jones <admin@danieljon.es>2020-06-24 11:21:58 +0930
commit167e63926ec8b06511bc03a897731c17e4564719 (patch)
treeed2e9973277613cc787e719d7760fcd7c814f35c /Gate.cpp
parent7c04b3433568e54d02e5b520cdd1bdd944464f4e (diff)
downloadfoxlogicgates-167e63926ec8b06511bc03a897731c17e4564719.tar.gz
foxlogicgates-167e63926ec8b06511bc03a897731c17e4564719.zip
possibly fix logic bug and add options panel
the option panel shows input types and output state. logic now updates when a new link is made
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 "?";
+ }
+
+}
+
+