CppLogicGateSimulator / gateNOT.cpp
gateNOT.cpp
Raw
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include "node.h"
#include "gateNOT.h"

gateNOT::gateNOT()
{
    configureEmpty();
}

gateNOT::gateNOT(string inName)
{
    configureName(inName);
}

gateNOT::gateNOT (node* input1, node* out)
{
    name = "NoName";
    inputs.push_back(input1);
    output = out;
}

int gateNOT::compute()
{
    //Check status of input
    if (!inputs[0]->alreadyComputed)    //input undefined
    {
        cout<<name<<" cannot be computed"<<endl;
        return -1;
    }
    output->setValue(!inputs[0]->value);
    return -1;
}