Defina uma nova classe que represente uma porta lógica AND com três entradas. Esta classe deve chamar-se AndGate3 e apresenta a mesma funcionalidade que a de duas entradas. A apresentação (toString) é A: valor B: valor C: valor.
A classe AndGate3 deve ser definida reutilizando o conceito AndGate2 (definido no Exercício 1).
Adapte a função main definida anteriormente, por forma a integrar alguns testes com a nova porta lógica.
In this solution we observe that the operation is a specialization of the previous one. This allows us to reuse the previous functionality.
Ficheiro AndGate3i.java |
---|
{{{2}}} |
In this solution, the 3-input gate is defined as a composition of 2-input gates. Note that the A-input of the second gate is updated whenever the inputs of the first gate are changed.
Ficheiro AndGate3c.java |
---|
{{{2}}} |