samples/apifest1/day2/subclassingsolution/src/org/netbeans/apifest/boolcircuit/FuzzyCircuit.java
4 * Created on July 13, 2006, 2:31 PM
6 * To change this template, choose Tools | Template Manager
7 * and open the template in the editor.
10 package org.netbeans.apifest.boolcircuit;
12 public abstract class FuzzyCircuit extends Circuit {
14 /** Feel free to implement and don't hesitate to throw IllegalArgumentEception
16 public abstract double evaluate(double... in);
18 public static final void checkParams( int expectedLenght, boolean... in ) {
20 // :-) in real world add a test for null too
22 if (expectedLenght != in.length) {
24 // :-) Probably unnecessary unless this is a competition
25 switch ( expectedLenght ) {
27 throw new IllegalArgumentException("Should have one parameter");
29 throw new IllegalArgumentException("Should have two parameters");
31 throw new IllegalArgumentException("Wrong number of parameters!");
36 public static final void checkParams( int expectedLenght, double ... in ) {
38 throw new IllegalArgumentException( "Parameter in must not be null!");
40 if (expectedLenght != in.length) {
41 throw new IllegalArgumentException("Wrong number of parameters!");
44 for( int i = 0; i < in.length; i++ ) {
45 if ( in[i] < 0.0 || in[i] > 1.0 ) {
46 throw new IllegalArgumentException(
47 "All params have to be in the range <0.0, 1.0>! " +
48 "param at index " + i + " is " + in[i]);