| 
									
										
										
										
											2020-04-14 11:01:51 +02:00
										 |  |  | public class ExorGate extends LogicGate {
 | 
					
						
							| 
									
										
										
										
											2020-04-14 11:29:26 +02:00
										 |  |  |     public ExorGate(final int inputnr) {
 | 
					
						
							| 
									
										
										
										
											2020-04-14 11:01:51 +02:00
										 |  |  |         super(inputnr);
 | 
					
						
							|  |  |  |         if (inputnr > 2)
 | 
					
						
							|  |  |  |             throw (new TooManyInputsException());
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-14 11:29:26 +02:00
										 |  |  |     public ExorGate(final DigitalInput... inputvals) {
 | 
					
						
							| 
									
										
										
										
											2020-04-14 11:01:51 +02:00
										 |  |  |         super(inputvals);
 | 
					
						
							|  |  |  |         if (inputvals.length > 2)
 | 
					
						
							|  |  |  |             throw (new TooManyInputsException());
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @Override
 | 
					
						
							|  |  |  |     public boolean getOutput() {
 | 
					
						
							|  |  |  |         boolean first = getInput(0).getValue();
 | 
					
						
							|  |  |  |         for (int i = 1; i < getInputNumber(); i++) {
 | 
					
						
							|  |  |  |             if (getInput(i).getValue() != first)
 | 
					
						
							|  |  |  |                 return true; // if there is one change return true
 | 
					
						
							|  |  |  |             first = getInput(i).getValue();
 | 
					
						
							|  |  |  |         }
 | 
					
						
							|  |  |  |         return false; // all values are the same...
 | 
					
						
							|  |  |  |     }
 | 
					
						
							| 
									
										
										
										
											2020-04-13 11:14:15 +02:00
										 |  |  | }
 |