private void calcDiscButton_Click(object sender, EventArgs e) { int i = 0; checks.ForEach(x => i += x.Checked ? 1 : 0); if (i == 0) { return; } IDiscountStrategy disc_strat = null; if (i == 1) { if (chkAE.Checked) { disc_strat = new AcademicExcellenceDiscount(); } else if (chkAM.Checked) { disc_strat = new AboriginalMinorityDiscount(); } else // if (chkFF.Checked) { disc_strat = new FreedomFighterDiscount(); } } else { CompositeDiscount ds = new CompositeDiscount(comboBox1.Text); if (chkAE.Checked) { ds.addDiscount(new AcademicExcellenceDiscount()); } if (chkAM.Checked) { ds.addDiscount(new AboriginalMinorityDiscount()); } if (chkFF.Checked) { ds.addDiscount(new FreedomFighterDiscount()); } disc_strat = ds; } rcc.getRegistration().setDiscountStrategy(disc_strat); GetChanged(rcc.getRegistration()); Program.play = true; }
public CompositeDiscount(string t) { discounts = new List <IDiscountStrategy>(); type = t; instance = this; }
public CompositeDiscount() { discounts = new List <IDiscountStrategy>(); instance = this; }