public decimal GetTotal() { decimal amount = strategy.GetPay(); decimal deductions = 1000; //intimate knowledge of the type has to be known //this downcast would make Barbara Liskov frown if (strategy is SalesStrategy) { decimal bonus = 1000; amount = amount + bonus; return amount - deductions; } else if (strategy is HourlyStrategy) { return amount - deductions; } return 0; //oops! }
public decimal GetTotalAfterDeductions() { decimal deductions = 1000; decimal amount = strategy.GetPay(); return amount - deductions; }