Guest User

Untitled

a guest
Mar 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. (import javax.swing.*)
  2. ;; Explicit import so we get JFrame.EXIT_ON_CLOSE
  3. (import javax.swing.JFrame)
  4. (import java.awt.event.ActionListener)
  5. (import java.awt.FlowLayout)
  6. (import java.awt.Color)
  7.  
  8. ;; ******************************
  9. ;; DEFGLOBALS
  10.  
  11. (defglobal ?*frame* = 0)
  12. (defglobal ?*contentPane* = 0)
  13. (defglobal ?*menu1* = 0)
  14. (defglobal ?*menu2* = 0)
  15. (defglobal ?*i* = 0)
  16. (defglobal ?*tickbox* = 0)
  17. (defglobal ?*button1* = 0)
  18. (defglobal ?*button2* = 0)
  19. ;; ******************************
  20. ;; DEFFUNCTIONS
  21. (defrule rule-1
  22. (or(enviroment "papers")
  23. (enviroment "manuals")
  24. (enviroment "documents")
  25. (enviroment "textbooks")
  26. )
  27. =>
  28. (assert (stimulus-situation "verbal")))
  29.  
  30.  
  31. (defrule rule-2
  32. (or(enviroment "pictures")
  33. (enviroment "illustrations")
  34. (enviroment "photographs")
  35. (enviroment "diagrams")
  36. )
  37. =>
  38. (assert (stimulus-situation "visual")))
  39.  
  40.  
  41. (defrule rule-3
  42. (or(enviroment "machines")
  43. (enviroment "buildings")
  44. (enviroment "tools")
  45. )
  46. =>
  47. (assert (stimulus-situation "physical object")))
  48.  
  49.  
  50. (defrule rule-4
  51. (or(enviroment "numbers")
  52. (enviroment "formulas")
  53. (enviroment "computer programs")
  54. )
  55. =>
  56. (assert (stimulus-situation "symbolic")))
  57.  
  58.  
  59. (defrule rule-5
  60. (or(job "lecturing")
  61. (job "advising")
  62. (job "troubleshooting")
  63. )
  64. =>
  65. (assert (stimulus-situation "oral")))
  66.  
  67.  
  68. (defrule rule-6
  69. (or(job "building")
  70. (job "repairing")
  71. (job "counselling")
  72. )
  73. =>
  74. (assert (stimulus-situation "hands-on")))
  75.  
  76.  
  77. (defrule rule-7
  78. (or(job "writing")
  79. (job "typing")
  80. (job "drawing")
  81. )
  82. =>
  83. (assert (stimulus-situation "documented")))
  84.  
  85.  
  86.  
  87. (defrule rule-8
  88. (or(job "evaluating")
  89. (job "reasoning")
  90. (job "investigating")
  91. )
  92. =>
  93. (assert (stimulus-situation "analytical")))
  94.  
  95.  
  96.  
  97. (defrule rule-9
  98. (and(stimulus_situation "physical object")
  99. (stimulus_response "hands-on")
  100. (feedback "TRUE")
  101. )
  102. =>
  103. (assert (medium "workshop")))
  104.  
  105.  
  106. (defrule rule-10
  107. (and(stimulus_situation "symbolic")
  108. (stimulus_response "analytical")
  109. (feedback "TRUE")
  110. )
  111. =>
  112. (assert (medium "lecture – tutorial")))
  113.  
  114.  
  115. (defrule rule-11
  116. (and(stimulus_situation "visual")
  117. (stimulus_response "documented")
  118. (feedback "NOT TRUE")
  119. )
  120. =>
  121. (assert (medium "videocassette")))
  122.  
  123.  
  124. (defrule rule-12
  125. (and(stimulus_situation "visual")
  126. (stimulus_response "oral")
  127. (feedback "TRUE")
  128. )
  129. =>
  130. (assert (medium "lecture – tutorial")))
  131.  
  132.  
  133. (defrule rule-13
  134. (and(stimulus_situation "verbal")
  135. (stimulus_response "analytical")
  136. (feedback "TRUE")
  137. )
  138. =>
  139. (assert (medium "lecture – tutorial")))
  140.  
  141.  
  142. (defrule rule-14
  143. (and(stimulus_situation "verbal")
  144. (stimulus_response "oral")
  145. (feedback "TRUE")
  146. )
  147. =>
  148. (assert (medium "role-play exercises")))
  149.  
  150. (deffunction create-frame ()
  151. (bind ?*frame* (new JFrame "Jess Reflection Demo"))
  152. (bind ?*contentPane* (?*frame* getContentPane))
  153. (?*contentPane* setLayout (new FlowLayout))
  154. (set ?*contentPane* background (Color.blue)))
  155.  
  156. (deffunction add-environs ()
  157. (?*contentPane* add (new JLabel "Environment: "))
  158. (bind ?*menu1* (new JComboBox))
  159. (?*menu1* addItem "papers")
  160. (?*menu1* addItem "manuals")
  161. (?*menu1* addItem "documents")
  162. (?*menu1* addItem "textbooks")
  163. (?*menu1* addItem "pictures")
  164. (?*menu1* addItem "illustrations")
  165. (?*menu1* addItem "photographs")
  166. (?*menu1* addItem "diagrams")
  167. (?*menu1* addItem "machines")
  168. (?*menu1* addItem "buildings")
  169. (?*menu1* addItem "tools")
  170. (?*menu1* addItem "numbers")
  171. (?*menu1* addItem "formulas")
  172. (?*menu1* addItem "computer programs")
  173. (?*contentPane* add ?*menu1* ))
  174.  
  175. (deffunction add-jobs ()
  176. (?*contentPane* add (new JLabel "Job: "))
  177. (bind ?*menu2* (new JComboBox))
  178. (?*menu2* addItem "lecturing")
  179. (?*menu2* addItem "advising")
  180. (?*menu2* addItem "counselling")
  181. (?*menu2* addItem "building")
  182. (?*menu2* addItem "repairing")
  183. (?*menu2* addItem "troubleshooting")
  184. (?*menu2* addItem "writing")
  185. (?*menu2* addItem "typing")
  186. (?*menu2* addItem "drawing")
  187. (?*menu2* addItem "evaluating")
  188. (?*menu2* addItem "reasoning")
  189. (?*menu2* addItem "investigating")
  190. (?*contentPane* add ?*menu2*))
  191.  
  192. (deffunction add-feedback ()
  193.  
  194. )
  195. (deffunction add-tick ()
  196. (bind ?*tickbox* (new JCheckBox "Feedback"))
  197. (?*contentPane* add ?*tickbox*)
  198.  
  199.  
  200. )
  201.  
  202. (deffunction add-button ()
  203. (bind ?*button1* (new JButton "Submit Enviroment"))
  204. (?*contentPane* add ?*button1*)
  205.  
  206. )
  207.  
  208. (deffunction add-button2 ()
  209. (bind ?*button2* (new JButton "Submit Job"))
  210. (?*contentPane* add ?*button2*)
  211.  
  212. )
  213.  
  214.  
  215.  
  216. ;(deffunction add-textbox ()
  217. ; (?*contentPane* add (new JPanel))
  218. ; (?*menu2* add LabelPane (), borderlayout.SOUTH)
  219. ; (?*menu2* add textfieldPane (), boderlayout.NORTH)
  220. ; (?*contentPane* add ?*menu2*)
  221. ;)
  222.  
  223.  
  224. (deffunction add-behaviours ()
  225. (?*frame* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))
  226.  
  227. (?*menu1* addActionListener (implement ActionListener using
  228. (lambda (?name ?event)
  229. (printout t "You chose: " (get ?*menu1* selectedItem) crlf))))
  230. (?*menu2* addActionListener (implement ActionListener using
  231. (lambda (?name ?event)
  232. (printout t "You chose: " (get ?*menu2* selectedItem) crlf))))
  233.  
  234. (?*button1* addActionListener (implement ActionListener using
  235. (lambda (?name ?event)
  236. (assert (enviroment (get ?*menu1* selectedItem)))
  237. )
  238. )
  239. )
  240. (?*button2* addActionListener (implement ActionListener using
  241. (lambda (?name ?event)
  242. (assert (job (get ?*menu2* selectedItem)))
  243. )
  244. )
  245. )
  246. (?*tickbox* addActionListener (implement ActionListener using
  247. (lambda (?name ?event)
  248. (assert (feedback "TRUE"))
  249. )
  250. )
  251. )
  252. )
  253.  
  254. (deffunction show-frame ()
  255. ;(?*frame* pack)
  256. (?*frame* setSize 400 100)
  257. (?*frame* setVisible TRUE))
  258.  
  259.  
  260. ;; ******************************
  261. ;; Run the program
  262.  
  263. (defrule init-rule
  264. (initial-fact)
  265. =>
  266. (create-frame)
  267. (add-environs)
  268. (add-jobs)
  269. ;(add-textbox)
  270. (add-tick)
  271. (add-button)
  272. (add-button2)
  273. (add-behaviours)
  274. (show-frame))
  275.  
  276. (reset)
  277. (run)
  278. (watch all)
  279. ;(rules)
Add Comment
Please, Sign In to add comment