diff --git a/scala_project_2025/bank_system/src/main/scala/Transaction.scala b/scala_project_2025/bank_system/src/main/scala/Transaction.scala index d959748..5b20b52 100644 --- a/scala_project_2025/bank_system/src/main/scala/Transaction.scala +++ b/scala_project_2025/bank_system/src/main/scala/Transaction.scala @@ -1,24 +1,22 @@ +import java.util.concurrent.ConcurrentLinkedQueue +import scala.collection.JavaConverters._ + object TransactionStatus extends Enumeration { val SUCCESS, PENDING, FAILED = Value } class TransactionPool { + private val queue = new ConcurrentLinkedQueue[Transaction]() - // Remove and the transaction from the pool - def remove(t: Transaction): Boolean = ??? + def add(t: Transaction): Boolean = queue.offer(t) - // Return whether the queue is empty - def isEmpty: Boolean = ??? + def remove(t: Transaction): Boolean = queue.remove(t) - // Return the size of the pool - def size: Integer = ??? + def isEmpty: Boolean = queue.isEmpty - // Add new element to the back of the queue - def add(t: Transaction): Boolean = ??? - - // Return an iterator to allow you to iterate over the queue - def iterator: Iterator[Transaction] = ??? + def size: Integer = queue.size + def iterator: Iterator[Transaction] = queue.iterator.asScala } class Transaction(