diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml index 9950095..cec0567 100644 --- a/.idea/checkstyle-idea.xml +++ b/.idea/checkstyle-idea.xml @@ -1,15 +1,35 @@ - 13.0.0 - JavaOnly + 13.1.0 + JavaOnlyWithTests + true true diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Transaction.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Transaction.java index e69de29..4030335 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Transaction.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Transaction.java @@ -0,0 +1,68 @@ +package edu.ntnu.idi.idatt2003.g40.mappe; + +/** + * Transaction abstract class. + * + *

Used for transactions

*/ +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; + } +}