与非门
Posted 一根PHP
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了与非门相关的知识,希望对你有一定的参考价值。
class NotAndGate extends Object{ private $_key1; private $_key2; public function setKey1($value){ $this->_key1 = $value; } public function setKey2($value){ $this->_key2 = $value; } public function getOutput(){ if (!$this->_key1 || !$this->_key2) return true; else if ($this->_key1 && $this->_key2) return false; } }
与非门有两个输入,当两个输入都为真时,与非门的输出为假,否则,输出为真。上面的代码中,与非 门类有两个成员变量, $_key1 和 $_key2 。但是有3个属性,表示2个输入的 key1 和 key2 ,以及表示输出的 output 。
以上是关于与非门的主要内容,如果未能解决你的问题,请参考以下文章