add simple evaluation to andGate

This commit is contained in:
Joel Beckmeyer 2017-04-10 19:49:35 -04:00
parent dfc6064bcd
commit 53198547c0

View File

@ -6,6 +6,9 @@ andGate::andGate(wire* wire1 = nullptr, wire* wire2 = nullptr,
wire* wire3 = nullptr) : in1(wire1), in2(wire2), out(wire3) {} wire* wire3 = nullptr) : in1(wire1), in2(wire2), out(wire3) {}
int andGate::evaluate(int evTime) { int andGate::evaluate(int evTime) {
int bool1 = in1 -> getValue(); int val1 = in1->getValue();
return ( in1 -> getValue(evTime) ) && ( in2 -> getValue(evTime) ); int val2 = in2->getValue();
if(val1 != -1 && val2 != -1) {
return val1 && val2;
}
} }