Created
January 1, 2017 06:45
-
-
Save chrisza4/e315cca14b5003607b107c5712e285b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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