<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ~~~ /* Strategy 策略模式: 它定義了算法家族,分別封裝起來,讓它們可以相互替換, 此模式讓算法的變化,不會影響到使用算法的客戶。 個人想法:UML圖很相似,策略模式是用在對多個做同樣事情(統一接口)的類對象的選擇上, 而狀態模式是:將對某個事情的處理過程抽象成接口和實現類的形式, 由context保存一份state,在state實現類處理事情時,修改狀態傳遞給context, 由context繼續傳遞到下一個狀態處理中, 作者: HCLAC 日期: 20170309 */ package strategy import ( "errors" ) type CashSuper interface { acceptCash(memory float32) float32 } type CashNomal struct { } func (this *CashNomal) acceptCash(money float32) float32 { return money } type CashRebate struct { meneyRebate float32 } func (this *CashRebate) acceptCash(money float32) float32 { return this.meneyRebate * money } type CashReturn struct { meneyCondition float32 meneyReturn float32 } func (this *CashReturn) acceptCash(money float32) float32 { if money >= this.meneyCondition { return money - float32(int(money/this.meneyCondition*this.meneyReturn)) } else { return money } } type Context struct { CashSuper } func NewCashContext(str string) (cash *Context, err error) { cash = new(Context) switch str { case "正常收費": cash.CashSuper = &CashNomal{} case "滿300返100": cash.CashSuper = &CashReturn{300, 100} case "打8折": cash.CashSuper = &CashRebate{0.8} default: err = errors.New("no match") } return cash, err } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看