001package scpc.model; 002 003import javax.script.ScriptException; 004 005/** 006 * Promotion rule that result in bonus item. 007 * <br>定義優惠的規則 008 * 009 * @author Kent Yeh 010 * @param <T> type of real cart item. 011 */ 012public interface ILeafRule<T> extends IRule<T> { 013 014 /** 015 * 優惠品項. 016 * 017 * @return Instance of Bonus. 018 */ 019 public IItem<T> getBonus(); 020 021 /** 022 * Current visit item is bonus item. 023 * <br>優惠品項就是當下走訪的品項 024 * 025 * @param item current visit item. 026 * @return Clone item when returning bonus is current visit item. 027 */ 028 public IItem<T> getCurrentAsBonus(IItem<T> item); 029 030 /** 031 * Quantity measure of bonus after {@link IRule#isTriggered(scpc.model.SingleItem) 032 * }. 033 * <br> 觸發觸發後,優惠品項的數量估值 034 * 035 * @return evulate quantity of bonus 036 * @throws ScriptException Error prone when quantity measure meet an error. 037 */ 038 public double evalQuantity() throws ScriptException; 039 040 /** 041 * Only the last measure set to quantity.<br> 042 * <br>只承認最後一次的數量估值 043 * 044 * @return whether the last measure set to quantity. 045 */ 046 public boolean isLastQuantityOnly(); 047 048}