acceptCash() public abstract method

public abstract acceptCash ( double money ) : double
money double
return double
Exemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //利用简单工厂模式根据下拉选择框,生成相应的对象
            CashSuper csuper = CashFactory.createCashAccept(cbxType.SelectedItem.ToString());
            //通过多态,可以得到收取费用的结果
            var totalPrices = csuper.acceptCash(Convert.ToDouble(txtPrice.Text) * Convert.ToDouble(txtNum.Text));

            total = total + totalPrices;
            lbxList.Items.Add("单价:" + txtPrice.Text + " 数量:" + txtNum.Text + " " + cbxType.SelectedItem + " 合计:" + totalPrices);
            lblResult.Text = total.ToString();
        }
Exemplo n.º 2
0
 //得到现金促销计算结果(利用了多态机制,不同的策略行为导致不同的结果)
 public double GetResult(double money)
 {
     return(cs.acceptCash(money));
 }