背著手扇扇子的人
          往事隨風......前事如夢......
          posts - 35,  comments - 17,  trackbacks - 0

          xxx購物超市折扣規則描述:
           1.任何顧客的購物總價大于1000元則享受9折優惠
           2.vip顧客的時候無論購物總價是多少享受7折優惠
           3.普通顧客沒有特別政策,另有規定的除外
           4.白金顧客享受8.5優惠,無論購物總價多少。
           5.黃金顧客享受9折優惠無論購物總價多少。
           6.任何顧客所夠商品中包含tv的時候,優惠后再優惠9.5折
          這個user case 是自己想的,不是很復雜

          對應的規則文件

          #created on: 2006-6-10
          #created by: kebo
          package com.sample

          import com.sample.Person;
          import com.sample.ShopCat;
          import com.sample.Product;
          import com.sample.Helper;


          rule "PRICE_DISCOUT"
           salience 2
           no-loop true
           when
            p:Person(c:cat->(c.getTotalPrice()>1000),discout==1)     
           then
            p.setDiscout(0.9);
            modify(p); 
          end

          rule "VIP"
           salience 3
           no-loop true
           when
            p:Person(type==Person.VIP,discout==1)     
           then
            p.setDiscout(0.7);
            modify(p); 
          end

          rule "COMMON"
           salience 3
           no-loop true
           when
            p:Person(type==Person.COMMON,discout==1)     
           then
            p.setDiscout(1);
            modify(p);
          end

          rule "PLATINA"
           salience 3
           no-loop true
           when
            p:Person(type==Person.PLATINA,discout==1)     
           then
            p.setDiscout(0.85); 
            modify(p);
          end

          rule "GOLD"
           salience 3
           no-loop true
           when
            p:Person(type==Person.GOLD,discout==1)     
           then  
            p.setDiscout(0.9); 
            modify(p);
          end

          rule "CONTAIN TV"
           salience 1
           no-loop true
           when
            p:Person(c:cat->(Helper.isContainType(c.getProducts(),Product.TV)))     
           then
            p.setDiscout(0.95 * p.getDiscout());
            modify(p);
          end

          解決rule的沖突還是比較麻煩的。

          為什么blogjava沒有code著色功能呢?代碼貼上去一點都不好看,唉!

           

           

          posted on 2006-06-13 01:19 kebo 閱讀(2044) 評論(0)  編輯  收藏 所屬分類: java

          <2006年6月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章檔案

          相冊

          收藏夾

          朋友

          搜索

          •  

          積分與排名

          • 積分 - 23395
          • 排名 - 1593

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 本溪| 林州市| 临潭县| 明星| 泸州市| 定陶县| 武威市| 富源县| 松桃| 朝阳县| 长泰县| 丽江市| 荃湾区| 望都县| 卓资县| 乌拉特中旗| 黎川县| 韶山市| 天峨县| 县级市| 武山县| 兴仁县| 宁阳县| 涞水县| 通化市| 怀来县| 洛扎县| 临海市| 呼玛县| 定结县| 长岭县| 安宁市| 即墨市| 乐东| 云霄县| 大荔县| 福海县| 五莲县| 昭平县| 钟山县| 六枝特区|