⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usedcar.clp

📁 介绍ANTLR使用的JAVA程序例子
💻 CLP
📖 第 1 页 / 共 4 页
字号:

         (defrule compile2
              (compile the problems)
              (CAR HAS BODY RUST)
         =>
              (printout t " The obvious rust shows the car could have"
              crlf "received better care than it was given." crlf
             "This problem will not likely effect the mechanics of"
              crlf "the car, but will gradually get worse unless" crlf
              "expensive repairs are done immediately." crlf crlf
              "Estimated Problem Value   20" crlf crlf crlf) (printout t
              "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 35)))


         (defrule compile3
              (compile the problems)
              (MAY HAVE FRAME DAMAGE)
              (EVIDENCE OF MAJOR ACCIDENT)
              (POSSIBLE BENT FRAME)
         =>
              (printout t crlf crlf crlf crlf crlf
              "This car has been involved in a serious accident" crlf
              "Run do not walk away from this deal. The bent " crlf
              "frame means costly repairs, and a dangerous car."crlf)
              (printout t crlf "Estimated Problem Value  100" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 100)))










         (defrule compile4
              (compile the problems)
              (CAR PULLS TO SIDE)
              (UNEVEN TIRE WEAR)

         =>
              (printout t crlf crlf crlf crlf crlf
              "There is strong evidence for front suspension " crlf
              "problems." crlf "This could be fixed by a front" crlf
              "end alignment, or the problem could be serious" crlf
              "enough for a complete rebuild of the front end" crlf
              "Have this checked by a good mechanic" crlf crlf
              "Estimated Problem Value   20" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 20)))



         (defrule compile5
              (compile the problems)
              (BAD SHOCKS)
              (UNEVEN TIRE WEAR)

         =>
              (printout t crlf crlf crlf crlf crlf
              "Bad shocks are causing poor tire wear. Replace" crlf
              "the shocks and ,if necessary, the tires." crlf crlf
              "Estimated Problem Value 5" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 5)))


         (defrule compile6
              (compile the problems)
              (UNEVEN TIRE PRESSURE)
              (CAR PULLS TO SIDE)

         =>
              (printout t crlf crlf crlf crlf crlf
              "Car pulls to side in part due to uneven air" crlf
              "pressure in the front tires. Check for leaks" crlf
              "to be sure tires are in good shape." crlf crlf
              "Estimated Problem Value 1" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 1)))



         (defrule compile7
              (compile the problems)
              (BELTS WORN)









         =>
              (printout t crlf crlf crlf crlf crlf
              "Worn engine belts indicate preventive maintenance" crlf
              "is lacking in this car. Make sure your inspection" crlf
              "is done with a fine toothed comb." crlf crlf
              "Estimated Problem Value 1" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 1)))



         (defrule compile8
              (compile the problems)
              (HOSES WORN)

         =>
              (printout t crlf crlf crlf crlf crlf
              "Worn engine hoses indicate preventive maintenance" crlf
              "is lacking in this car. Make sure your inspection" crlf
              "is done with a fine toothed comb." crlf crlf
              "Estimated Problem Value 1" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 1)))



         (defrule compile9
              (compile the problems)
              (FUEL SYSTEM LEAKING)

         =>
              (printout t crlf crlf crlf crlf crlf
              "The gas smell indicates a serious leak in the " crlf
              "fuel system which could result in a fire. Do not " crlf
              "drive the car in this condition!" crlf crlf
              "Estimated Problem Value 50" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 50)))



         (defrule compile10
              (compile the problems)
              (CATALYTIC CONVERTER MISSING)

         =>
              (printout t crlf crlf crlf crlf crlf
              "The missing catalytic converter indicates the car" crlf
              "has been modified illegally. You will not be able" crlf
              "to drive this on any road until. the converter" crlf








              "is replaced. Check for other evidence of modifications"
              crlf crlf "Estimated Problem Value 20" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 20)))


         (defrule compile11
              (compile the problems)
              (OIL IN EXHAUST)

         =>
              (printout t crlf crlf crlf crlf crlf
              "Blue exhaust shows advanced engine wear. High" crlf
              "expenses make this problem serious." crlf crlf
              "Estimated Problem Value 80" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 80)))


         (defrule compile12
              (compile the problems)
              (STEERING JUMPS)
              (CAR PULLS TO SIDE)
              (options powers yes)

         =>
              (printout t crlf crlf crlf crlf crlf
              "There is a problem in the power steering system" crlf
              "causing the car to pull. The pulling will get "    crlf
              "worse unless the steering control valve is replaced"
              crlf crlf "Estimated Problem Value 22" crlf crlf)
              (printout t "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 22)))



         (defrule compile13
              (compile the problems)
              (FAILING UJOINTS)
         =>
              (printout t crlf crlf crlf crlf crlf
              "The clunk when the transmission is placed into gear"
              crlf "is caused by the drive shaft. In time the drive"
              crlf "shaft will fall out. The fix is to replace the"
              crlf "u-joints, a relatively minor operation" crlf crlf
              "Estimated Problem Value  10" crlf crlf
              "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 10)))










         (defrule compile14
              (compile the problems)
              (POSSIBLE TIRE OUT OUT OF BALANCE)
         =>
              (printout t crlf crlf crlf crlf crlf
              "The increasing vibrations are caused by an out of"crlf
              "balance tire" crlf crlf
              "Estimated Problem Value  5" crlf crlf
              "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 5)))


         (defrule compile15
              (compile the problems)
              (PROBLEM WITH THIRD MEMBER)
         =>
              (printout t crlf crlf crlf crlf crlf
              "The sound from the rear end indicates a problem" crlf
              "with the ring and pinion gears. Excessive wear is" crlf
              "is likely to cause premature failure." crlf crlf
              "Estimated Problem Value 30" crlf crlf
              "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 30)))



         (defrule compile16
              (compile the problems)
              (LOWER ENGINE PROBLEM)
         =>
              (printout t crlf crlf crlf crlf crlf
              "The deep clunking noise from the engine indicates" crlf
              "a major engine failure in the making. This calls for"
              crlf "a complete engine rebuild" crlf crlf
              "Estimated Problem Value  90" crlf crlf
              "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 90)))


         (defrule compile17
              (compile the problems)
              (UPPER ENGINE NOISE)
         =>
              (printout t crlf crlf crlf crlf crlf
              "The ticking indicates a valve train problem" crlf
              "that might range from a simple adjustment to severe"
              crlf "wear.                        " crlf crlf
              "Estimated Problem Value 30" crlf crlf
              "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 30)))








         (defrule compile18
              (compile the problems)
              (COOLING SYSTEM PROBLEM)
              (WATER IN EXHAUST GAS)
         =>
              (printout t crlf crlf crlf crlf crlf
              "The white exhaust is caused by water mixing" crlf
              "with the fuel as it burns. A head gasket leak" crlf
              "is the most common cause. When the gasket leak" crlf
              "gets worse, serious damage could occur." crlf crlf
              "Estimated Problem Value 60" crlf crlf
              "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 60)))


         (defrule compile18
              (compile the problems)
              (CARBON IN EXHAUST GAS)
         =>
              (printout t crlf crlf crlf crlf crlf
              "The black exhaust can be caused by many things," crlf
              "from bad spark plugs to a faulty choke. Most" crlf
              "problems can be solved at minor cost." crlf crlf
              "Estimated Problem Value 7" crlf crlf
              "Hit <cr> to proceed" crlf)
              (bind ?answer (readline))
              (assert (estimated value 7)))




         (defrule recomend1
              (declare (salience -100))
              (estimated total ?value)
              (compile the problems)
              (test (>= ?value 100))
         =>
              (printout t crlf crlf crlf crlf crlf
              "                "
              "R  E  C  O  M  M  E  N  D  A  T  I  O  N" crlf crlf
              "                         DO NOT BUY THIS CAR" crlf crlf
              " There is too much wrong for this car to be " crlf
              " considered to be dependable." crlf crlf crlf crlf
              crlf))



         (defrule recomend2
              (declare (salience -100))
              (estimated total ?value)
              (compile the problems)
              (test (and (>= ?value 80)
                        (< ?value 100)))








         =>
              (printout t crlf crlf crlf crlf crlf
              "                "
              "R  E  C  O  M  M  E  N  D  A  T  I  O  N" crlf crlf
              "                   THIS IS NOT A GOOD CHOICE" crlf crlf
              " Unless you can't live without this car or you" crlf
              " have a friend that's a mechanic, leave it alone" crlf
              crlf crlf crlf crlf crlf))



         (defrule recomend3
              (declare (salience -100))
              (estimated total ?value)
              (compile the problems)
              (test (and (>= ?value 40)
                        (< ?value 60)))
         =>
              (printout t crlf crlf crlf crlf crlf
              "                "
              "R  E  C  O  M  M  E  N  D  A  T  I  O  N" crlf crlf
              "                        A REASONABLE CHOICE" crlf crlf
              " There are some problems with the car but they" crlf
              " may not be too serious. If you can't find a" crlf
              " better deal, this will do." crlf crlf crlf crlf crlf
              crlf))



         (defrule recomend4
              (declare (salience -100))
              (estimated total ?value)
              (compile the problems)
              (test (and (>= ?value 60)
                        (< ?value 80)))
         =>
              (printout t crlf crlf crlf crlf crlf
              "                "
              "R  E  C  O  M  M  E  N  D  A  T  I  O  N" crlf crlf
              "                      A QUESTIONABLE CHOICE " crlf crlf
              " There are many problems with the car. If you" crlf
              " are a good mechanic this one's for you. If " crlf
              " not, keep on looking!     " crlf crlf crlf crlf crlf
              crlf))




         (defrule recomend5
              (declare (salience -100))
              (estimated total ?value)
              (compile the problems)
              (test (and (>= ?value 20)
                        (< ?value 40)))








         =>
              (printout t crlf crlf crlf crlf crlf
              "                "
              "R  E  C  O  M  M  E  N  D  A  T  I  O  N" crlf crlf
              "                        A GOOD CHOICE      " crlf crlf
              " There are few problems with the car. Some    " crlf
              " items may need quick attention, but as a " crlf
              " whole the car is not bad." crlf crlf crlf crlf crlf
              crlf))


         (defrule recomend6
              (declare (salience -100))
              (estimated total ?value)
              (compile the problems)
              (test (and (>= ?value 0)
                        (< ?value 20)))
         =>
              (printout t crlf crlf crlf crlf crlf
              "                "
              "R  E  C  O  M  M  E  N  D  A  T  I  O  N" crlf crlf
              "                        BUY IT              " crlf crlf
              " Minor problems exist but no car is perfect.  " crlf
              " This car should be a good dependable means " crlf
              " of transportation.        " crlf crlf crlf crlf crlf
              crlf))



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -