-
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.
- TransactionCalculatorFactory - PurchaseCalculatorFactory - SaleCalculatorFactory
- Loading branch information
Nikollai
committed
Apr 8, 2026
1 parent
5fab027
commit 043369c
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/millions/calculators/PurchaseCalculatorFactory.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,18 @@ | ||
| package millions.calculators; | ||
|
|
||
| import millions.Share; | ||
|
|
||
| public class PurchaseCalculatorFactory extends TransactionCalculatorFactory { | ||
| Share share; | ||
|
|
||
| @Override | ||
| public void setShare(Share share) { | ||
| this.share = share; | ||
| } | ||
|
|
||
| @Override | ||
| public TransactionCalculator createCalculator() { | ||
| return new PurchaseCalculator(share); | ||
| } | ||
|
|
||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/java/millions/calculators/SaleCalculatorFactory.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,16 @@ | ||
| package millions.calculators; | ||
|
|
||
| import millions.Share; | ||
|
|
||
| public class SaleCalculatorFactory extends TransactionCalculatorFactory { | ||
| Share share; | ||
|
|
||
| @Override | ||
| public void setShare(Share share) { | ||
| this.share = share; | ||
| } | ||
| @Override | ||
| public TransactionCalculator createCalculator() { | ||
| return new SaleCalculator(share); | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/millions/calculators/TransactionCalculatorFactory.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,8 @@ | ||
| package millions.calculators; | ||
|
|
||
| import millions.Share; | ||
|
|
||
| public abstract class TransactionCalculatorFactory { | ||
| public abstract void setShare(Share share); | ||
| public abstract TransactionCalculator createCalculator(); | ||
| } |