-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Checkstyle to PurchaseCalculator
- Loading branch information
Showing
1 changed file
with
28 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,38 @@ | ||
| package Model; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| /** | ||
| * PurchaseCalculator class that does calculations. | ||
| */ | ||
| public class PurchaseCalculator implements TransactionCalculator { | ||
| private BigDecimal purchasePrice; | ||
| private BigDecimal quantity; | ||
| private final BigDecimal purchasePrice; | ||
| private final BigDecimal quantity; | ||
|
|
||
| public PurchaseCalculator(Share share) { | ||
| this.purchasePrice = share.getPurchasePrice(); | ||
| this.quantity = share.getQuantity(); | ||
| } | ||
| public PurchaseCalculator(Share share) { | ||
| this.purchasePrice = share.getPurchasePrice(); | ||
| this.quantity = share.getQuantity(); | ||
| } | ||
|
|
||
| public BigDecimal calculateGross() { | ||
| return this.purchasePrice.multiply(this.quantity); | ||
| } | ||
| @Override | ||
| public BigDecimal calculateGross() { | ||
| return this.purchasePrice.multiply(this.quantity); | ||
| } | ||
|
|
||
| public BigDecimal calculateCommission() { | ||
| BigDecimal rate = new BigDecimal("0.005"); | ||
| return calculateGross().multiply(rate); | ||
| } | ||
| @Override | ||
| public BigDecimal calculateCommission() { | ||
| BigDecimal rate = new BigDecimal("0.005"); | ||
| return calculateGross().multiply(rate); | ||
| } | ||
|
|
||
| public BigDecimal calculateTax() { | ||
| BigDecimal tax = new BigDecimal("0"); | ||
| return tax; | ||
| } | ||
| @Override | ||
| public BigDecimal calculateTax() { | ||
| BigDecimal tax = new BigDecimal("0"); | ||
| return tax; | ||
| } | ||
|
|
||
| public BigDecimal calculateTotal() { | ||
| return calculateGross().add(calculateCommission()).add(calculateTax()); | ||
| } | ||
| @Override | ||
| public BigDecimal calculateTotal() { | ||
| return calculateGross().add(calculateCommission()).add(calculateTax()); | ||
| } | ||
| } |