-
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.
Implement skeleton for Transaction, Purchase, Sale and TransactionArc…
…hive classes
- Loading branch information
Showing
4 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
16 changes: 15 additions & 1 deletion
16
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.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 |
|---|---|---|
| @@ -1,6 +1,20 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.PurchaseCalculator; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.TransactionCalculator; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Player; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Share; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| public class Purchase { | ||
| public class Purchase extends Transaction { | ||
|
|
||
| public Purchase(Share share, int week) { | ||
| super(share, week, new PurchaseCalculator(share)); | ||
| } | ||
|
|
||
| @Override | ||
| public void commit(Player player) { | ||
|
|
||
| } | ||
| } |
15 changes: 14 additions & 1 deletion
15
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Sale.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 |
|---|---|---|
| @@ -1,4 +1,17 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction; | ||
|
|
||
| public class Sale { | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.SaleCalculator; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Player; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Share; | ||
|
|
||
| public class Sale extends Transaction { | ||
|
|
||
| public Sale(Share share, int week) { | ||
| super(share, week, new SaleCalculator(share)); | ||
| } | ||
|
|
||
| @Override | ||
| public void commit(Player player) { | ||
|
|
||
| } | ||
| } |
38 changes: 37 additions & 1 deletion
38
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Transaction.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 |
|---|---|---|
| @@ -1,4 +1,40 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction; | ||
|
|
||
| public class Transaction { | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.TransactionCalculator; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Player; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Share; | ||
|
|
||
| public abstract class Transaction { | ||
| private Share share; | ||
| private int week; | ||
| private TransactionCalculator calculator; | ||
| private boolean committed; | ||
|
|
||
| protected Transaction(Share share, int week, TransactionCalculator calculator) { | ||
| this.share = share; | ||
| this.week = week; | ||
| this.calculator = calculator; | ||
| this.committed = false; | ||
| } | ||
|
|
||
| public Share getShare() { | ||
| return share; | ||
| } | ||
|
|
||
| public int getWeek() { | ||
| return week; | ||
| } | ||
|
|
||
| public TransactionCalculator getCalculator() { | ||
| return calculator; | ||
| } | ||
|
|
||
| public boolean isCommitted() { | ||
| return committed; | ||
| } | ||
|
|
||
| public void commit(Player player) { | ||
|
|
||
| } | ||
|
|
||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchive.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 |
|---|---|---|
| @@ -1,4 +1,36 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class TransactionArchive { | ||
| private List<Transaction> transactions; | ||
|
|
||
| public TransactionArchive() { | ||
| this.transactions = new ArrayList<>(); | ||
| } | ||
|
|
||
| public boolean add(Transaction transaction) { | ||
| return true; | ||
| } | ||
|
|
||
| public boolean isEmpty() { | ||
| return true; | ||
| } | ||
|
|
||
| public List<Transaction> getTransactions(int week) { | ||
| return transactions; | ||
| } | ||
|
|
||
| public List<Purchase> getPurchases(int week) { | ||
| return null; | ||
| } | ||
|
|
||
| public List<Sale> getSales(int week) { | ||
| return null; | ||
| } | ||
|
|
||
| public int countDistinctWeeks() { | ||
| return 0; | ||
| } | ||
| } |