|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.uci.ics.inf111.dvdvendor.app.TransactionDB
public class TransactionDB
The TransactionDB class encapsulates the list of all products sold in the store. In a real system, this would likely be a wrapper around a database of products which would be managed elsewhere. In our sample system, we have a method which can provide a sample DB, and the capability to add items to the DB using an addItem() method. The TransactionDB is persisted in a file.
Field Summary | |
---|---|
private Persistence |
persistence
Persistence object that will help persist the database information in a file |
private java.util.ArrayList<Transaction> |
transactions
This ArrayList of Transactions is the core of our sample DB. |
Constructor Summary | |
---|---|
TransactionDB()
Constructs an empty database. |
Method Summary | |
---|---|
void |
addItem(Transaction transaction)
This method is called to add items directly to the database in our example. |
RentTransaction |
findLastRentTransaction(BarCode barCode)
This method finds the last Rent Transaction in the database for a specific BarCode. |
ReturnTransaction |
findLastReturnTransaction(BarCode barCode)
This method finds the last Return Transaction in the database for a specific BarCode. |
void |
initializeTestDB()
This test method constructs the transaction database from a txt file that contains all the transactions. |
java.util.ArrayList<Transaction> |
listAll()
This method returns a copy of the TransactionDB ArrayList. |
java.lang.String |
persistTransaction(Transaction transaction)
This method is called to persist a Transaction in the Transaction file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.ArrayList<Transaction> transactions
private Persistence persistence
Constructor Detail |
---|
public TransactionDB()
Method Detail |
---|
public void initializeTestDB() throws java.lang.Exception
java.lang.Exception
public java.util.ArrayList<Transaction> listAll()
public RentTransaction findLastRentTransaction(BarCode barCode) throws TransactionDBException
barCode
- The bar code of the product involved in the Rent Transaction
TransactionDBException
public ReturnTransaction findLastReturnTransaction(BarCode barCode) throws TransactionDBException
barCode
- The bar code of the product involved in the Return Transaction
TransactionDBException
public void addItem(Transaction transaction)
transaction
- The transaction to be added.public java.lang.String persistTransaction(Transaction transaction) throws PersistenceException
transaction
- The transaction to be persisted in the file.
PersistenceException
- If the transaction passed as a parameter is null
or if there is an error while writing the file.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |