//--------------------------------------------------------------------- // Add a new transaction to the list // params: (in) //--------------------------------------------------------------------- public void AddTransaction(Transaction inData) { TransactionNode newTransaction = new TransactionNode(); newTransaction.Data = inData; newTransaction.next = head; head = newTransaction; transactionCount += 1; }
//--------------------------------------------------------------------- // Returns the most recent transaction // params: none //--------------------------------------------------------------------- public Transaction getLastTransaction() { TransactionNode transPtr = head; if (head == null) { return(null); } else { while (transPtr.next != null) { transPtr = transPtr.next; } return(transPtr.Data); } }
//--------------------------------------------------------------------- // Retrieves the transaction from the transaction history at // specified index // params: (in) //--------------------------------------------------------------------- public Transaction getTransaction(int index) { TransactionNode transPtr = head; if (index == 0) { return(head.Data); } else { for (int i = 0; i < index; i++) { transPtr = transPtr.next; } return(transPtr.Data); } }
//--------------------------------------------------------------------- // Clears transaction history // params: none //--------------------------------------------------------------------- public void clear() { this.transactionCount = 0; this.head = null; }