1
5 public class HalfAdderComponent {
6
7 private Gate[] gate = new Gate[6];
9
10 public HalfAdderComponent(Gate x, Gate y) {
11
12 gate[0] = new Gate("NOT", x); gate[1] = new Gate("NOT", y); gate[2] = new Gate(gate[0], "AND", y); gate[3] = new Gate(x, "AND", gate[1]); gate[4] = new Gate(gate[2], "OR", gate[3]); gate[5] = new Gate(x, "AND", y); }
20
21 public void operate() {
23 for (int i=0; i<gate.length; i++)
24 gate[i].operate();
25 }
26
27 public Gate getSum() {
29 return gate[4];
30 }
31
32 public Gate getCarry() {
34 return gate[5];
35 }
36
37 }
38