Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (import javax.swing.*)
- ;; Explicit import so we get JFrame.EXIT_ON_CLOSE
- (import javax.swing.JFrame)
- (import java.awt.event.ActionListener)
- (import java.awt.FlowLayout)
- (import java.awt.Color)
- ;; ******************************
- ;; DEFGLOBALS
- (defglobal ?*frame* = 0)
- (defglobal ?*contentPane* = 0)
- (defglobal ?*menu1* = 0)
- (defglobal ?*menu2* = 0)
- (defglobal ?*i* = 0)
- (defglobal ?*tickbox* = 0)
- (defglobal ?*button1* = 0)
- (defglobal ?*button2* = 0)
- ;; ******************************
- ;; DEFFUNCTIONS
- (defrule rule-1
- (or(enviroment "papers")
- (enviroment "manuals")
- (enviroment "documents")
- (enviroment "textbooks")
- )
- =>
- (assert (stimulus-situation "verbal")))
- (defrule rule-2
- (or(enviroment "pictures")
- (enviroment "illustrations")
- (enviroment "photographs")
- (enviroment "diagrams")
- )
- =>
- (assert (stimulus-situation "visual")))
- (defrule rule-3
- (or(enviroment "machines")
- (enviroment "buildings")
- (enviroment "tools")
- )
- =>
- (assert (stimulus-situation "physical object")))
- (defrule rule-4
- (or(enviroment "numbers")
- (enviroment "formulas")
- (enviroment "computer programs")
- )
- =>
- (assert (stimulus-situation "symbolic")))
- (defrule rule-5
- (or(job "lecturing")
- (job "advising")
- (job "troubleshooting")
- )
- =>
- (assert (stimulus-situation "oral")))
- (defrule rule-6
- (or(job "building")
- (job "repairing")
- (job "counselling")
- )
- =>
- (assert (stimulus-situation "hands-on")))
- (defrule rule-7
- (or(job "writing")
- (job "typing")
- (job "drawing")
- )
- =>
- (assert (stimulus-situation "documented")))
- (defrule rule-8
- (or(job "evaluating")
- (job "reasoning")
- (job "investigating")
- )
- =>
- (assert (stimulus-situation "analytical")))
- (defrule rule-9
- (and(stimulus_situation "physical object")
- (stimulus_response "hands-on")
- (feedback "TRUE")
- )
- =>
- (assert (medium "workshop")))
- (defrule rule-10
- (and(stimulus_situation "symbolic")
- (stimulus_response "analytical")
- (feedback "TRUE")
- )
- =>
- (assert (medium "lecture – tutorial")))
- (defrule rule-11
- (and(stimulus_situation "visual")
- (stimulus_response "documented")
- (feedback "NOT TRUE")
- )
- =>
- (assert (medium "videocassette")))
- (defrule rule-12
- (and(stimulus_situation "visual")
- (stimulus_response "oral")
- (feedback "TRUE")
- )
- =>
- (assert (medium "lecture – tutorial")))
- (defrule rule-13
- (and(stimulus_situation "verbal")
- (stimulus_response "analytical")
- (feedback "TRUE")
- )
- =>
- (assert (medium "lecture – tutorial")))
- (defrule rule-14
- (and(stimulus_situation "verbal")
- (stimulus_response "oral")
- (feedback "TRUE")
- )
- =>
- (assert (medium "role-play exercises")))
- (deffunction create-frame ()
- (bind ?*frame* (new JFrame "Jess Reflection Demo"))
- (bind ?*contentPane* (?*frame* getContentPane))
- (?*contentPane* setLayout (new FlowLayout))
- (set ?*contentPane* background (Color.blue)))
- (deffunction add-environs ()
- (?*contentPane* add (new JLabel "Environment: "))
- (bind ?*menu1* (new JComboBox))
- (?*menu1* addItem "papers")
- (?*menu1* addItem "manuals")
- (?*menu1* addItem "documents")
- (?*menu1* addItem "textbooks")
- (?*menu1* addItem "pictures")
- (?*menu1* addItem "illustrations")
- (?*menu1* addItem "photographs")
- (?*menu1* addItem "diagrams")
- (?*menu1* addItem "machines")
- (?*menu1* addItem "buildings")
- (?*menu1* addItem "tools")
- (?*menu1* addItem "numbers")
- (?*menu1* addItem "formulas")
- (?*menu1* addItem "computer programs")
- (?*contentPane* add ?*menu1* ))
- (deffunction add-jobs ()
- (?*contentPane* add (new JLabel "Job: "))
- (bind ?*menu2* (new JComboBox))
- (?*menu2* addItem "lecturing")
- (?*menu2* addItem "advising")
- (?*menu2* addItem "counselling")
- (?*menu2* addItem "building")
- (?*menu2* addItem "repairing")
- (?*menu2* addItem "troubleshooting")
- (?*menu2* addItem "writing")
- (?*menu2* addItem "typing")
- (?*menu2* addItem "drawing")
- (?*menu2* addItem "evaluating")
- (?*menu2* addItem "reasoning")
- (?*menu2* addItem "investigating")
- (?*contentPane* add ?*menu2*))
- (deffunction add-feedback ()
- )
- (deffunction add-tick ()
- (bind ?*tickbox* (new JCheckBox "Feedback"))
- (?*contentPane* add ?*tickbox*)
- )
- (deffunction add-button ()
- (bind ?*button1* (new JButton "Submit Enviroment"))
- (?*contentPane* add ?*button1*)
- )
- (deffunction add-button2 ()
- (bind ?*button2* (new JButton "Submit Job"))
- (?*contentPane* add ?*button2*)
- )
- ;(deffunction add-textbox ()
- ; (?*contentPane* add (new JPanel))
- ; (?*menu2* add LabelPane (), borderlayout.SOUTH)
- ; (?*menu2* add textfieldPane (), boderlayout.NORTH)
- ; (?*contentPane* add ?*menu2*)
- ;)
- (deffunction add-behaviours ()
- (?*frame* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))
- (?*menu1* addActionListener (implement ActionListener using
- (lambda (?name ?event)
- (printout t "You chose: " (get ?*menu1* selectedItem) crlf))))
- (?*menu2* addActionListener (implement ActionListener using
- (lambda (?name ?event)
- (printout t "You chose: " (get ?*menu2* selectedItem) crlf))))
- (?*button1* addActionListener (implement ActionListener using
- (lambda (?name ?event)
- (assert (enviroment (get ?*menu1* selectedItem)))
- )
- )
- )
- (?*button2* addActionListener (implement ActionListener using
- (lambda (?name ?event)
- (assert (job (get ?*menu2* selectedItem)))
- )
- )
- )
- (?*tickbox* addActionListener (implement ActionListener using
- (lambda (?name ?event)
- (assert (feedback "TRUE"))
- )
- )
- )
- )
- (deffunction show-frame ()
- ;(?*frame* pack)
- (?*frame* setSize 400 100)
- (?*frame* setVisible TRUE))
- ;; ******************************
- ;; Run the program
- (defrule init-rule
- (initial-fact)
- =>
- (create-frame)
- (add-environs)
- (add-jobs)
- ;(add-textbox)
- (add-tick)
- (add-button)
- (add-button2)
- (add-behaviours)
- (show-frame))
- (reset)
- (run)
- (watch all)
- ;(rules)
Add Comment
Please, Sign In to add comment