背着手扇扇子的人
往事随风......前事如梦......
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 阅读(2032) 评论(0)  编辑  收藏 所属分类: java

只有注册用户登录后才能发表评论。


网站导航:
 

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

常用链接

留言簿(1)

随笔分类

随笔档案

文章档案

相册

收藏夹

朋友

搜索

  •  

积分与排名

  • 积分 - 22489
  • 排名 - 1607

最新评论

阅读排行榜

评论排行榜