Skip to content

Instantly share code, notes, and snippets.

@chrisza4
Created January 1, 2017 06:45
Show Gist options
  • Select an option

  • Save chrisza4/e315cca14b5003607b107c5712e285b9 to your computer and use it in GitHub Desktop.

Select an option

Save chrisza4/e315cca14b5003607b107c5712e285b9 to your computer and use it in GitHub Desktop.
public class InvoiceNormal {
private bool isCalculateSpecialTax;
private List<InvoiceItem> items;
public class InvoiceItem {
public int quantity;
public string description;
public double pricePerUnit;
}
public InvoiceNormal(bool isCalculateSpecialTax) {
this.isCalculateSpecialTax = isCalculateSpecialTax;
}
public double calculateSumPrice () {
var price = 0.0;
price = this.calculateSumPriceForNormalCase();
if (this.isCalculateSpecialTax) {
price = this.plusVat(price) * 1.05;
}
return price;
}
private double calculateSumPriceForNormalCase () {
return items.sum(d => d.quantity * d.pricePerUnit);
}
private double plusVat (double price) {
return price * 1.07;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment