1
7 public class FullAdder extends CompoundComponent {
8
9
11 public FullAdder(Signal x, Signal y, Signal cIn) {
12
13 super();
14
15 HalfAdder ha1 = new HalfAdder(x, y); HalfAdder ha2 = new HalfAdder(ha1.getSum(), cIn); Gate or = new Or(ha1.getCarry(), ha2.getCarry());
20 addComponent(ha1);
22 addComponent(ha2);
23 addComponent(or);
24 }
25
26 public Signal getSum() {
28 return ((HalfAdder)getComponent(1)).getSum();
29 }
30
31 public Signal getCarryOut() {
33 return ((Gate)getComponent(2)).out();
34 }
35
36 public int size() {
38 return 3;
39 }
40
41 }
42