Skip to content

26 transaction class. #43

Merged
merged 3 commits into from
Feb 19, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions .idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Transaction.java
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;
}
}