Skip to content

Commit

Permalink
* The Java part should be fine (bug not free).
Browse files Browse the repository at this point in the history
  • Loading branch information
Feng Liu committed Dec 18, 2009
1 parent b7665f0 commit 872ad93
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
35 changes: 34 additions & 1 deletion JudgeEngine.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import model.*;
import jess.*;
import java.util.Iterator;

public class JudgeEngine {
private Rete engine;
Expand All @@ -14,8 +15,40 @@ public JudgeEngine(SystemDatabase aDatabase) throws JessException {

database = aDatabase;
engine.addAll(database.getCourses());
engine.addAll(database.getStudents());
// engine.addAll(database.getStudents());

// loadCoursesData();

marker = engine.mark();
}
/*
private void loadCoursesData() throws JessException {
Courses courses = database.getCourses();
for (Iterator iter = courses.iterator(); iter.hasNext();) {
Course course = (Course) iter.next();
engine.add(course);
}
}
*/

private void loadStudentsData(int sID) throws JessException {
Student student = database.getStudent(sID);

if (student != null) {
engine.add(student);
// engine.addAll(student.getCourseTaken());
}
}

private Iterator run(int sID, String cID, String secID) throws JessException {
engine.resetToMark(marker);

loadStudentsData(sID);
engine.add(new Register(sID, cID, secID));

engine.run();

return engine.getObjects(new Filter.ByClass(Decision.class));
}
}
4 changes: 4 additions & 0 deletions SystemDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ public Collection getStudents() {
public String toString() {
return courses.size() + "\n\n" + students.size();
}

public Student getStudent(int sID) {
return (Student) students.get(new Integer(sID));
}
}
13 changes: 13 additions & 0 deletions model/Register.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package model;

public class Register {
private int sID;
private String cID;
private String secID;

public Register(int sid, String cid, String secid) {
this.sID = sid;
this.cID = cid;
this.secID = secid;
}
}
4 changes: 4 additions & 0 deletions model/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public Student(int id, String name, String ctaken) {

courseToTake = new Vector();
}

public Vector getCoursesTaken() {
return courseTaken;
}
}

0 comments on commit 872ad93

Please sign in to comment.