-
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.
Merge pull request #43 from Team-40-IDATT2003/26-transaction-class
26 transaction class.
- Loading branch information
Showing
2 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,68 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe; | ||
|
|
||
| /** | ||
| * Transaction abstract class. | ||
| * | ||
| * <p>Used for transactions</p> */ | ||
| public abstract class Transaction { | ||
|
|
||
| private final Share share; | ||
|
|
||
| private final int week; | ||
|
|
||
| private final TransactionCalculator calculator; | ||
|
|
||
| private boolean commited = false; | ||
|
|
||
| /** | ||
| * Creates a new {@code Transaction} with a share, week and calculator. | ||
| * | ||
| * @param share the share to perform the transaction on | ||
| * @param week the current week to perform the transaction under | ||
| */ | ||
|
|
||
| protected Transaction(final Share share, final int week, | ||
| final TransactionCalculator calculator) { | ||
| this.share = share; | ||
| this.week = week; | ||
| this.calculator = calculator; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the share this transaction was made on. | ||
| * | ||
| * @return share*/ | ||
| public Share getShare() { | ||
| return share; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the week this transaction was made during. | ||
| * | ||
| * @return week*/ | ||
| public int getWeek() { | ||
| return week; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the calculator used by this transaction. | ||
| * | ||
| * @return calculator | ||
| */ | ||
| public TransactionCalculator getCalculator() { | ||
| return calculator; | ||
| } | ||
|
|
||
| /** | ||
| * Returns whether this transaction has been commited or not. | ||
| * | ||
| * @return commited*/ | ||
| public boolean isCommited() { | ||
| return commited; | ||
| } | ||
|
|
||
| /** Commits the transaction. */ | ||
| public void commit() { | ||
| commited = true; | ||
| } | ||
| } |