samples/apifest1/day2/pinbasedsolution/src/org/netbeans/apifest/boolcircuit/Element.java
1.1 --- a/samples/apifest1/day2/pinbasedsolution/src/org/netbeans/apifest/boolcircuit/Element.java Sat Jun 14 09:52:52 2008 +0200
1.2 +++ b/samples/apifest1/day2/pinbasedsolution/src/org/netbeans/apifest/boolcircuit/Element.java Sat Jun 14 09:56:12 2008 +0200
1.3 @@ -1,22 +1,14 @@
1.4 -/*
1.5 - * Element.java
1.6 - *
1.7 - * Created on 12. Ĩervenec 2006, 14:14
1.8 - *
1.9 - * To change this template, choose Tools | Template Manager
1.10 - * and open the template in the editor.
1.11 - */
1.12 -
1.13 package org.netbeans.apifest.boolcircuit;
1.14
1.15 /**
1.16 * Representation of an element in the circuit.
1.17 - * The internal behaviour of the element is opaque to the API user, it can only
1.18 - * be used as a building block for logical equations, using primitive operation
1.19 - * factories and a factory for input pin representation.
1.20 - * Elements are chained to create the logical net. The inputs to the net are
1.21 - * represented by the elements created by {@link #createInput(boolean[])}
1.22 - * factory method.
1.23 + * The internal behaviour of the element is opaque to the API user,
1.24 + * it can only be used as a building block for logical equations,
1.25 + * using primitive operation factories and a factory for input
1.26 + * pin representation.
1.27 + * Elements are chained to create the logical net.
1.28 + * The inputs to the net are represented by the elements created
1.29 + * by {@link #createInput(boolean[])} factory method.
1.30 */
1.31 public abstract class Element {
1.32
1.33 @@ -34,7 +26,9 @@
1.34 * Creates an Element representing 2-input AND function.
1.35 *
1.36 */
1.37 - public static Element createAnd(final Element source1, final Element source2) {
1.38 + public static Element createAnd(
1.39 + final Element source1, final Element source2
1.40 + ) {
1.41 return new Element() {
1.42 double evaluate(double[] inputs) {
1.43 return source1.evaluate(inputs) * source2.evaluate(inputs);
1.44 @@ -50,7 +44,9 @@
1.45 * Creates an Element representing 2-input OR function.
1.46 *
1.47 */
1.48 - public static Element createOr(final Element source1, final Element source2) {
1.49 + public static Element createOr(
1.50 + final Element source1, final Element source2
1.51 + ) {
1.52 return new Element() {
1.53 double evaluate(double[] inputs) {
1.54 double x = source1.evaluate(inputs);
1.55 @@ -100,13 +96,17 @@
1.56 /**
1.57 * Creates an Element with user-defined transfer function.
1.58 */
1.59 - public static Element createGate(final Element source1, final Element source2, final Function function) {
1.60 + public static Element createGate(
1.61 + final Element source1, final Element source2, final Function function
1.62 + ) {
1.63 return new Element() {
1.64 double evaluate(double[] inputs) {
1.65 double x = source1.evaluate(inputs);
1.66 double y = source2.evaluate(inputs);
1.67 double result = function.evaluate(x, y);
1.68 - if (result < 0.0 || result > 1.0) throw new InternalError("Illegal gate function");
1.69 + if (result < 0.0 || result > 1.0) {
1.70 + throw new InternalError("Illegal gate function");
1.71 + }
1.72 return result;
1.73 }
1.74