Guest User

Untitled

a guest
May 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. package com.sample
  2.  
  3. dialect "mvel"  
  4.  
  5. import com.sample.SodaWater.Customer  
  6.    
  7.  
  8. rule "buy a soda water and drink"  
  9.     when  
  10.         $c : Customer(money > 0, $m:money, $b:blankCup, $d:drinkSum)  
  11.     then  
  12.         $c.money = $m - 1;  
  13.         $c.blankCup = $b + 1;  
  14.         $c.drinkSum = $d + 1;  
  15.         System.out.println( "Customer " + $c.name + " now buy a soda water and drink: money=" + $c.money + " and blankCup=" + $c.blankCup);  
  16.         update($c);  
  17. end  
  18.  
  19. rule "sale blank cup and get money"  
  20.     when  
  21.         $c : Customer(blankCup > 1, $b:blankCup, $m:money )  
  22.     then  
  23.         $c.blankCup = $b - 2;  
  24.         $c.money = $m + 1;  
  25.         System.out.println("Customer " + $c.name + " now sale 2 cups and get money: money=" + $c.money + ", blankCup=" + $c.blankCup);  
  26.         update($c);  
  27. end  
  28.  
  29. rule "finish drink"            
  30.     no-loop true    
  31.     dialect "java"  
  32.     when  
  33.         $c : Customer(blankCup < 2, money == 0)  
  34.     then  
  35.         System.out.println( "Customer " + $c.getName() + " finished drink, and drink number is " + $c.getDrinkSum() + " blankCup=" + $c.getBlankCup());  
  36. end
Add Comment
Please, Sign In to add comment