Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


abstract strategy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public abstract class TaxStrategy{

  private final Double FEDERAL_TAX = 0.5d;

  public abstract Double calculate(Double subtotal);

  public static TaxStrategy createConcreteTaxA(){ //factory method used for concrete-strategy creation

    return new ConcreteTax(0.6d //provincialTax);

  }

}

concrete strategy A

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class ConcreteTax extends TaxStrategy{

  private Double provincialTax;

  public ConcreteTax(Double provincialTax){
    this.provincialTax = provincialTax;
  }


  public Double calculate(Double subtotal){
    // complex calculation
    return //result of calculation
  }

}

client code that uses the strategy

1
2
3
4
TaxStrategy strategy = TaxStrategy.createConcreteTaxA();

Double result = strategy.calculateStrategy(100.58);