jtulach@52: /* jtulach@52: * The contents of this file are subject to the terms of the Common Development jtulach@52: * and Distribution License (the License). You may not use this file except in jtulach@52: * compliance with the License. jtulach@52: * jtulach@52: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html jtulach@52: * or http://www.netbeans.org/cddl.txt. jtulach@52: * jtulach@52: * When distributing Covered Code, include this CDDL Header Notice in each file jtulach@52: * and include the License file at http://www.netbeans.org/cddl.txt. jtulach@52: * If applicable, add the following below the CDDL Header, with the fields jtulach@52: * enclosed by brackets [] replaced by your own identifying information: jtulach@52: * "Portions Copyrighted [year] [name of copyright owner]" jtulach@52: * jtulach@52: * The Original Software is NetBeans. The Initial Developer of the Original jtulach@52: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun jtulach@52: * Microsystems, Inc. All Rights Reserved. jtulach@52: */ jtulach@52: jtulach@52: package org.netbeans.apifest.boolcircuit; jtulach@52: jtulach@52: // BEGIN: apifest.day1.parsingsolution.Circuit jtulach@52: /** jtulach@52: * Usage: jtulach@52: * First method parse must be called with valid logical expression on input. jtulach@52: * If it returns zero then it is possible to call method evaluate with array jtulach@52: * of input values as parameter. Method evaluate can be invoked many time with jtulach@52: * different input values. jtulach@52: * Method parse can be called anytime to change logical expression. jtulach@52: */ jtulach@52: public class Circuit { jtulach@52: jtulach@52: /** Parses logical expression jtulach@52: * @param string representation of logical expression jtulach@52: * Valid tokens: jtulach@52: * Input values are represented by x and number starting from 1 eg.: x1 jtulach@52: * AND, NOT, OR and brackets '(',')' can be used. jtulach@52: * Example of valid expression: x1 AND x2 jtulach@132: * @return 0 when input expression is validated and parsed. jtulach@132: * Return nonzero value otherwise. jtulach@52: */ jtulach@52: public int parse(String expression) { jtulach@52: return 0; jtulach@52: } jtulach@52: jtulach@52: /** Evaluate logical expression jtulach@132: * @param array of boolean input values. Size of array must jtulach@132: * correspond to number of variables used in expression jtulach@132: * If size of array is bigger then only first N values are used jtulach@132: * to evaluate expression. Remaining values are ignored. jtulach@52: * If size of array is smaller then IllegalArgumentException is thrown. jtulach@132: * If no expression is set by method parse then jtulach@132: * IllegalStateException is thrown. jtulach@52: */ jtulach@52: public boolean evaluate(boolean [] x) { jtulach@52: return true; jtulach@52: jtulach@52: } jtulach@52: jtulach@52: } jtulach@52: // END: apifest.day1.parsingsolution.Circuit jtulach@52: