aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 16:01:30 +0200
committerUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 16:01:30 +0200
commit8d64376c70e4f291f1a8fb24488cb713216eb1f9 (patch)
treeb79ec04598f1fd3f0b675b9dc4bef0afe5128c77
parent8dafb610811a34f0ec49e7484942341cf78bb6f6 (diff)
WIP And gate w/ crack main function
-rw-r--r--GateAnd.cpp2
-rw-r--r--Node.cpp1
-rw-r--r--main.cpp24
3 files changed, 16 insertions, 11 deletions
diff --git a/GateAnd.cpp b/GateAnd.cpp
index d14d7f6..487f8bc 100644
--- a/GateAnd.cpp
+++ b/GateAnd.cpp
@@ -9,7 +9,7 @@ SignalLevel GateAnd::level() {
if (this->inputs.size() < 1) throw CircuitException("AndGate input size error");
for (int i = 0; i < this->inputs.size(); i++){
- SignalLevel l this->inputs[i]->getLevel();
+ SignalLevel l = this->inputs[i]->getLevel();
if (l == UNDEFINED) return UNDEFINED;
if (l == LOW) return LOW;
diff --git a/Node.cpp b/Node.cpp
index d3564da..75f94e5 100644
--- a/Node.cpp
+++ b/Node.cpp
@@ -10,6 +10,7 @@ Node::Node(const char * type) {
void Node::addInput(Net * net) {
net->attach(this);
+ inputs.push_back(net);
}
void Node::setOutput(Net * net){
diff --git a/main.cpp b/main.cpp
index 5fcfb3e..032a812 100644
--- a/main.cpp
+++ b/main.cpp
@@ -15,16 +15,20 @@ int main() {
// Observer ob();
Net n, n1, o;
Node *g = new GateAnd;
- g->addInput(&n);
- g->addInput(&n1);
- g->setOutput(&o);
-
- // o.setLevel(UNDEFINED);
- n.setLevel(LOW);
- n1.setLevel(LOW);
- int level = 22;
- level = o.getLevel();
- printf("hello world! %d\n", level);
+ try {
+ g->addInput(&n);
+ g->addInput(&n1);
+ g->setOutput(&o);
+
+ // o.setLevel(UNDEFINED);
+ n.setLevel(HIGH);
+ n1.setLevel(HIGH);
+ int level = 22;
+ level = o.getLevel();
+ printf("hello world! %d\n", level);
+ } catch(Exception& e) {
+ std::cerr << e.what() << '\n';
+ }
return 0;
}