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:56:12 2008 +0200
1.2 +++ b/samples/apifest1/day2/pinbasedsolution/src/org/netbeans/apifest/boolcircuit/Element.java Sat Jun 14 09:58:08 2008 +0200
1.3 @@ -1,14 +1,22 @@
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,
1.18 - * it can only be used as a building block for logical equations,
1.19 - * using primitive operation factories and a factory for input
1.20 - * pin representation.
1.21 - * Elements are chained to create the logical net.
1.22 - * The inputs to the net are represented by the elements created
1.23 - * by {@link #createInput(boolean[])} factory method.
1.24 + * The internal behaviour of the element is opaque to the API user, it can only
1.25 + * be used as a building block for logical equations, using primitive operation
1.26 + * factories and a factory for input pin representation.
1.27 + * Elements are chained to create the logical net. The inputs to the net are
1.28 + * represented by the elements created by {@link #createInput(boolean[])}
1.29 + * factory method.
1.30 */
1.31 public abstract class Element {
1.32
1.33 @@ -26,9 +34,7 @@
1.34 * Creates an Element representing 2-input AND function.
1.35 *
1.36 */
1.37 - public static Element createAnd(
1.38 - final Element source1, final Element source2
1.39 - ) {
1.40 + public static Element createAnd(final Element source1, final Element source2) {
1.41 return new Element() {
1.42 double evaluate(double[] inputs) {
1.43 return source1.evaluate(inputs) * source2.evaluate(inputs);
1.44 @@ -44,9 +50,7 @@
1.45 * Creates an Element representing 2-input OR function.
1.46 *
1.47 */
1.48 - public static Element createOr(
1.49 - final Element source1, final Element source2
1.50 - ) {
1.51 + public static Element createOr(final Element source1, final Element source2) {
1.52 return new Element() {
1.53 double evaluate(double[] inputs) {
1.54 double x = source1.evaluate(inputs);
1.55 @@ -96,17 +100,13 @@
1.56 /**
1.57 * Creates an Element with user-defined transfer function.
1.58 */
1.59 - public static Element createGate(
1.60 - final Element source1, final Element source2, final Function function
1.61 - ) {
1.62 + public static Element createGate(final Element source1, final Element source2, final Function function) {
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) {
1.69 - throw new InternalError("Illegal gate function");
1.70 - }
1.71 + if (result < 0.0 || result > 1.0) throw new InternalError("Illegal gate function");
1.72 return result;
1.73 }
1.74