protected void Page_Load(object sender, EventArgs e) { var basepay = CalculateBaseFactory.CalBasePay; var leavepay = CalculateLeavePayFactory.CalLeavePay; var otpay = CalculateOtFactory.CalOtPay; var wagecal = new CalculateWage(); wagecal.BasePay = basepay; wagecal.OtPay = otpay; wagecal.LeavePay = leavepay; int result = wagecal.Calculate(); Response.Write(result); }
protected void Page_Load(object sender, EventArgs e) { var cus = "A"; var basepay = new CalculateBasePay(); var leavepay = new CalculateLeavePay(); ICalculate otpay; switch (cus) { case "A": otpay = new CalculateOtPayA(); break; case "B": otpay = new CalculateOtPayB(); break; case "C": otpay = new CalculateOtPayC(); break; default: otpay = new CalculateOtPay(); break; } var wagecal = new CalculateWage(); wagecal.BasePay = basepay; wagecal.OtPay = otpay; wagecal.LeavePay = leavepay; int result = wagecal.Calculate(); Response.Write(result); }