Exemplo n.º 1
0
    public function output()
    {
        return $this->left->output() & $this->right->output();
    }
}
class OrGate extends Gate
{
    public function output()
    {
        return $this->left->output() | $this->right->output();
    }
}
class LShiftGate extends Gate
{
    public function output()
    {
        return $this->left->output() << $this->right->output();
    }
}
class RShiftGate extends Gate
{
    public function output()
    {
        return $this->left->output() >> $this->right->output();
    }
}
$circ = new Circuit();
$out = $circ->getNode('a')->output();
$circ->reset();
$circ->setNode('b', new RawValue($out));
echo 'Answer: a -> ' . $circ->getNode('a')->output() . PHP_EOL;