-
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.
- Loading branch information
Showing
1 changed file
with
36 additions
and
32 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,42 +1,46 @@ | ||
| package Model; | ||
|
|
||
| /** | ||
| * Transaction class. | ||
| */ | ||
| public abstract class Transaction { | ||
| private Share share; | ||
| private int week; | ||
| private TransactionCalculator calculator; | ||
| protected boolean committed; | ||
|
|
||
| protected Transaction(Share share, int week, TransactionCalculator calculator) { | ||
| if (share == null) { | ||
| throw new IllegalArgumentException("Share cannot be null"); | ||
| } | ||
| if (week < 1) { | ||
| throw new IllegalArgumentException("Week must be at least 1"); | ||
| } | ||
| if (calculator == null) { | ||
| throw new IllegalArgumentException("Calculator cannot be null"); | ||
| } | ||
|
|
||
| this.share = share; | ||
| this.week = week; | ||
| this.calculator = calculator; | ||
| } | ||
| private Share share; | ||
| private int week; | ||
| private TransactionCalculator calculator; | ||
| protected boolean committed; | ||
|
|
||
| public Share getShare() { | ||
| return this.share; | ||
| protected Transaction(Share share, int week, TransactionCalculator calculator) { | ||
| if (share == null) { | ||
| throw new IllegalArgumentException("Share cannot be null"); | ||
| } | ||
|
|
||
| public int getWeek() { | ||
| return this.week; | ||
| if (week < 1) { | ||
| throw new IllegalArgumentException("Week must be at least 1"); | ||
| } | ||
|
|
||
| public TransactionCalculator getCalculator() { | ||
| return this.calculator; | ||
| if (calculator == null) { | ||
| throw new IllegalArgumentException("Calculator cannot be null"); | ||
| } | ||
|
|
||
| public boolean isCommitted() { | ||
| return this.committed; | ||
| } | ||
| this.share = share; | ||
| this.week = week; | ||
| this.calculator = calculator; | ||
| } | ||
|
|
||
| public Share getShare() { | ||
| return this.share; | ||
| } | ||
|
|
||
| public int getWeek() { | ||
| return this.week; | ||
| } | ||
|
|
||
| public TransactionCalculator getCalculator() { | ||
| return this.calculator; | ||
| } | ||
|
|
||
| public boolean isCommitted() { | ||
| return this.committed; | ||
| } | ||
|
|
||
| public abstract void commit(Player player); | ||
| public abstract void commit(Player player); | ||
|
|
||
| } |