import java.util.ArrayList;
import java.util.Iterator;

import jess.*;

/**
 * @author sanket
 *
 */
public class Test {
	Rete r = new Rete();
	ArrayList factsList = new ArrayList();
	public static void main(String[] args) {
		Test test = new Test();
		try {
			test.r.executeCommand("(reset)");
			test.r.executeCommand("(batch test.clp)");
			Iterator it = test.r.listFacts();
			while(it.hasNext()){
				test.factsList.add(((Fact)it.next()).clone());
			}
			test.r.executeCommand("(facts)");
			test.r.executeCommand("(run)");
			test.r.executeCommand("(reset)");
			System.out.println("\nRestoring saved facts: ");
			it = test.factsList.iterator();
			while(it.hasNext()){
				test.r.assertFact((Fact)it.next());
			}
			test.r.executeCommand("(facts)");
			test.r.run();
		} catch (JessException e) {
			e.printStackTrace();
		}
		
	}
}
