I think Dr. Friedman-Hill wrote:
>>So everywhere you've got a line like the above, change it to
>> if(slotType[i].equals("double"))
Indeed. I modified your code like Ernest suggested....
import jess.*;
import java.io.*;
public class TestBug2 {
public static void main(String[] unused) throws IOException,
JessException {
Rete r = new Rete();
BufferedReader lesen = new BufferedReader(new InputStreamReader(
System.in));
//Eingabe den Namen vom Fact
System.out.println("Fact-Name ?:");
String factName = lesen.readLine();//Gibt factName= name ein
System.out.println("How many Slots ?:");
String _anzahl = lesen.readLine();
//String slotname[];
Integer i1 = new Integer(_anzahl);
int anzahl = i1.intValue();
String[] slotName = new String[anzahl];
String[] slotWert = new String[anzahl];
String[] slotType = new String[anzahl];
//Deftemplate
Deftemplate dt = new Deftemplate(factName, " Nur ein Name ", r);
for (int i = 0; i < anzahl; i++) {
System.out.println("Give a slot name:");
slotName[i] = lesen.readLine();
System.out.println("Give a value:");
slotWert[i] = lesen.readLine();
System.out.println("Give a slot type:");
slotType[i] = lesen.readLine();
if (slotType[i].equals("int")) {
Value zero = new Value(0, RU.INTEGER);
dt.addSlot(slotName[i], zero, "INTEGER");
System.out.println("Bin hier");
}
if (slotType[i].equals("double")) {
Value zero = new Value(0, RU.FLOAT);
dt.addSlot(slotName[i], zero, "FLOAT");
System.out.println("Bin hier");
}
if (slotType[i].equals("String")) {
Value zero = new Value(0, RU.STRING);
dt.addSlot(slotName[i], zero, "STRING");
System.out.println("Bin hier");
}
}
r.addDeftemplate(dt);
//Deffacts
Fact f = new Fact(factName, r);
for (int i = 0; i < anzahl; i++) {
System.out.println(slotType[i]);
if (slotType[i].equals("int")) {
Integer i2 = new Integer(slotWert[i]);
int iwert = i2.intValue();
f.setSlotValue(slotName[i], new Value(iwert, RU.INTEGER));
System.out.println("Bin hier");
} else
;
if (slotType[i].equals("double")) {
Double d1 = new Double(slotWert[i]);
double dwert = d1.doubleValue();
f.setSlotValue(slotName[i], new Value(dwert, RU.FLOAT));
System.out.println("Bin hier");
} else
;
if (slotType[i].equals("String")) {
f.setSlotValue(slotName[i], new Value(slotWert[i],
RU.STRING));
System.out.println("Bin hier");
}
//else;
}
System.out.println("Bin hier");
r.assertFact(f);
r.executeCommand("(facts)");
}
}
... and I got
Fact-Name ?:
metal
How many Slots ?:
3
Give a slot name:
name
Give a value:
steel-1020
Give a slot type:
STRING
Give a slot name:
strength-tensile-MPa
Give a value:
440
Give a slot type:
INTEGER
Give a slot name:
strength-yield-MPa
Give a value:
330
Give a slot type:
INTEGER
STRING
INTEGER
INTEGER
Bin hier
f-0 (MAIN::metal)
For a total of 1 facts.
Cheers,
JM
------------------------
Jason Morris
Morris Technical Solutions
[EMAIL PROTECTED]
www.morristechnicalsolutions.com
fax/phone: 503.692.1088
--------------------------------------------------------------------
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]
--------------------------------------------------------------------