samples/apifest1/day2/RealTest.java
changeset 132 3bc4c54f4bcc
parent 53 a0b47629aad8
child 133 50bf1b976c0d
     1.1 --- a/samples/apifest1/day2/RealTest.java	Sat Jun 14 09:52:47 2008 +0200
     1.2 +++ b/samples/apifest1/day2/RealTest.java	Sat Jun 14 09:56:12 2008 +0200
     1.3 @@ -1,37 +1,12 @@
     1.4 -/*
     1.5 - * The contents of this file are subject to the terms of the Common Development
     1.6 - * and Distribution License (the License). You may not use this file except in
     1.7 - * compliance with the License.
     1.8 - *
     1.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    1.10 - * or http://www.netbeans.org/cddl.txt.
    1.11 - *
    1.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
    1.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
    1.14 - * If applicable, add the following below the CDDL Header, with the fields
    1.15 - * enclosed by brackets [] replaced by your own identifying information:
    1.16 - * "Portions Copyrighted [year] [name of copyright owner]"
    1.17 - *
    1.18 - * The Original Software is NetBeans. The Initial Developer of the Original
    1.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    1.20 - * Microsystems, Inc. All Rights Reserved.
    1.21 - */
    1.22 -
    1.23  package org.netbeans.apifest.boolcircuit;
    1.24  
    1.25 -import java.security.CodeSource;
    1.26 -import java.security.Permission;
    1.27 -import java.security.PermissionCollection;
    1.28 -import java.security.Policy;
    1.29 -import java.util.Collection;
    1.30 -import java.util.Collections;
    1.31 -import java.util.Enumeration;
    1.32  import junit.framework.TestCase;
    1.33  import junit.framework.*;
    1.34  
    1.35  // BEGIN: apitest.day2.RealTest
    1.36  /** This file contains the APIFest quest for day 2. Simply, turn the 
    1.37 - * boolean circuit into circuit that can compute with double values from 0 to 1.
    1.38 + * boolean circuit into circuit that can compute with double 
    1.39 + * values from 0 to 1.
    1.40   * <p>
    1.41   * This means that where ever a boolean was used to represent input or 
    1.42   * output values, one can now use any double number from >= 0 and <= 1.
    1.43 @@ -39,21 +14,23 @@
    1.44   * has to be kept available and have to work. In fact False shall be 
    1.45   * treated as 0 and True as 1.
    1.46   * <p>
    1.47 - * The basic elements has to be modified to work on doubles in the following
    1.48 - * way:
    1.49 + * The basic elements has to be modified to work on doubles
    1.50 + * in the following way:
    1.51   * <ul>
    1.52 - *   <li>negation - neg(x) = 1 - x, this is correct extension as neg(false)=neg(0)=1-0=1=true
    1.53 - *   <li>and - and(x,y) = x * y, again this is fine as and(true,true)=1*1=true and also
    1.54 + *   <li>negation - neg(x) = 1 - x, this is correct extension as 
    1.55 + *                  neg(false)=neg(0)=1-0=1=true
    1.56 + *   <li>and - and(x,y) = x * y, again this is fine as 
    1.57 + *             and(true,true)=1*1=true and also
    1.58   *             and(false,true)=0*1=0=false
    1.59   *   <li>or - or(x,y) = 1 - (1 - x) * (1 - y) and this is also ok as
    1.60 - *             or(false,false) = 1 - (1 - 0) * (1 - 0) = 1 - 1 = 0 = false
    1.61 - *             or(true,false) = 1 - (1 - 1) * (1 - 0) = 1 - 0 * 1 = 1 = true
    1.62 + *            or(false,false) = 1 - (1 - 0) * (1 - 0) = 1 - 1 = 0 = false
    1.63 + *            or(true,false) = 1 - (1 - 1) * (1 - 0) = 1 - 0 * 1 = 1 = true
    1.64   * </ul>
    1.65   * <p>
    1.66 - * However as the circuits with doubles are more rich than plain boolean circuits,
    1.67 - * there is additional requirement to allow any user of your API to write its 
    1.68 - * own "element" type. This is all going to be exercise in the tests bellow
    1.69 - * which you are supposed to implement.
    1.70 + * However as the circuits with doubles are more rich than plain boolean 
    1.71 + * circuits, there is additional requirement to allow any user of your API 
    1.72 + * to write its own "element" type. This is all going to be exercise in 
    1.73 + * the tests bellow which you are supposed to implement.
    1.74   */
    1.75  public class RealTest extends TestCase {
    1.76      static {
    1.77 @@ -77,7 +54,8 @@
    1.78       *
    1.79       * Feed the same circuit with x1=0.5, x2=0.5, assert result is 0.625
    1.80       *
    1.81 -     * Feed the same circuit with x1=0.0, x2=2.0, make sure it throws an exception
    1.82 +     * Feed the same circuit with x1=0.0, x2=2.0, make sure it 
    1.83 +     * throws an exception
    1.84       */
    1.85      public void testX1andX2orNotX1() {
    1.86          fail("testX1andX2orNotX1");
    1.87 @@ -94,7 +72,8 @@
    1.88          fail("testImproperUseOfTheCircuit");
    1.89      }
    1.90      
    1.91 -    /** Write your own element type called "gte" that will have two inputs and one output.
    1.92 +    /** Write your own element type called "gte" that will have two 
    1.93 +     * inputs and one output.
    1.94       * The output value will be 1 if x1 >= x2 and 0 otherwise. 
    1.95       * 
    1.96       * Create