Toy Example - Gnorion/BizVR GitHub Wiki

Applying Methods

toy=toy.price toy=toy.tax toy=toy.shipping toy=toy.total

image

Composing Methods

toy=toy.price.tax.shipping.total

image

Defining Composed Methods (not sure this is the best example - mep)

define 
    model Toys
         color, size, shape, weight number,
         price number, tax number, shipping number, total number
    method : finalTotal
       return applyPricingRules.applyTaxRules.applyShippingRules.ApplyTotalRules
    DT : applyPricingRules
         if color='red' then price = 5
         if size='small' and shape='square' then price =10
         if shape ='round' then price =20
         return toy
    DT : applyTaxRules
         tax = price * 0.075
         return toy
    DT : applyShippingRules
         if weight > 100 then shipping = 8
         if weight <=100 then shipping = 5
         return toy
    DT : applyTotalRules
         total = price + tax + shipping
         return toy

.finalTotal may now be used in place of .price.tax.shipping.total

image