On Fri, 2003-07-25 at 08:13, [EMAIL PROTECTED] wrote:

> Now, I'm not really sure where JUnit fits in.

You're absolutely right. Java/Jess conditionals should suffice.

Thanks for the boost! Hope you don't mind some follow-on questions. 

The main one being, I don't understand why the deftemplate rule is
needed. I know that's Jess's way of defining a jess object with a slot
(instance var) for the object under test. Is that "just the way it has
to be in Jess" or is there a deeper reason? In any event, I'd never have
guessed this on my own, so thanks!

Style question: I got the JessInsideJava style from the examples
but understand many permutations are possible. Would you recommend this
style for this application, i.e. where the defrule section will grow
interminably?

Finally, it compiled, ran, but the "subject passes" rule didn't fire.
Any advice on debugging tips would be great. Feel free to blow me off on
this one; I'm sure I saw it in the dox somewhere.

Here's what I made of what you sent

package edu.virtc.gauges;
public class Helmet implements MilitaryEquipment
{
        public Helmet()
        {
                super();
        }
        public double getWeight()
        {
                return 5.0;
        }
}
=========
package edu.virtc.gauges;
public interface MilitaryEquipment
{
        double getWeight();
}
==========
package edu.virtc.gauges;

import jess.JessException;
import jess.Rete;

public class Rules
{
        public static void main(String[] argv)
        {
                try
                        {
                                Rete rete = new Rete();

                                rete.executeCommand(
                                        "(deftemplate test-subject (slot object))"
                                );
                                rete.executeCommand(
                                        "(assert (test-subject (object (new 
edu.virtc.gauges.Helmet))))"
                                );
                                rete.executeCommand(
                                        "(deffunction compareWeights (?n1 ?n2)\n"+
                                        "       (return (< (call Math abs (- ?n1 ?n2)) 
0.000001)))\n"
                                );
                                rete.executeCommand(
                                        "(deffunction computeWeight (?o)\n"+
                                        "       (return 5.00))\n"
                                );
                                rete.executeCommand(
                                        "(defrule test-get-weight\n"+
                                        "                       (test-subject (object 
?o))\n"+
                                        "                       (test (instanceof ?o 
edu.virtc.gauges.MilitaryEquipment))\n"+
                                        "                       (test (compareWeights 
(?o getWeight) (computeWeight ?o)))\n"+
                                        "                       =>\n"+
                                        "                       (printout \"Subject 
passes getWeight test\" crlf))\n"
                                        );
                                rete.reset();
                                rete.run();

                                // System.out.println("The answer is NOT: " + 
rete.fetch("RESULT"));
                        }
                catch (JessException re)
                        {
                                re.printStackTrace();
                        }
        }
}

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to