-
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.
created PurchaseCalculator Created SaleCalculator
- Loading branch information
Nikollai
committed
Feb 12, 2026
1 parent
ed22c38
commit aab0f7b
Showing
6 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
src/main/java/Portfolio.java → src/main/java/temppackage/Portfolio.java
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,3 +1,5 @@ | ||
| package temppackage; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
|
|
||
2 changes: 2 additions & 0 deletions
2
src/main/java/Share.java → src/main/java/temppackage/Share.java
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,3 +1,5 @@ | ||
| package temppackage; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| public class Share { | ||
|
|
||
2 changes: 2 additions & 0 deletions
2
src/main/java/Stock.java → src/main/java/temppackage/Stock.java
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,3 +1,5 @@ | ||
| package temppackage; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.List; | ||
|
|
||
|
|
||
31 changes: 31 additions & 0 deletions
31
src/main/java/temppackage/calculators/PurchaseCalculator.java
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package temppackage.calculators; | ||
|
|
||
| import temppackage.Share; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| public class PurchaseCalculator implements TransactionCalculator { | ||
| BigDecimal purchasePrice; | ||
| BigDecimal quantity; | ||
| public PurchaseCalculator(Share share) { | ||
| super(); | ||
| this.purchasePrice = share.getPurchasePrice(); | ||
| this.quantity = share.getQuantity(); | ||
| } | ||
| @Override | ||
| public BigDecimal calculateGross() { | ||
| return this.purchasePrice.multiply(this.quantity); | ||
| } | ||
| @Override | ||
| public BigDecimal calculateComission() { | ||
| return this.calculateGross().multiply(new BigDecimal("0.05")); | ||
| } | ||
| @Override | ||
| public BigDecimal calculateTax() { | ||
| return new BigDecimal("0"); | ||
| } | ||
| @Override | ||
| public BigDecimal calculateTotal() { | ||
| return this.calculateGross().add(this.calculateTax().add(this.calculateComission())) ; | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package temppackage.calculators; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import temppackage.Share; | ||
|
|
||
| public class SaleCalculator { | ||
| BigDecimal purchasePrice; | ||
| BigDecimal salesPrice; | ||
| BigDecimal quantity; | ||
| public SaleCalculator(Share share) { | ||
| super(); | ||
| this.purchasePrice = share.getPurchasePrice(); | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
...va/calculators/TransactionCalculator.java → ...ge/calculators/TransactionCalculator.java
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,4 +1,4 @@ | ||
| package calculators; | ||
| package temppackage.calculators; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
|
|
||