Class ShopQueueService
java.lang.Object
com.iu.javadatastructureslab.services.QueueService<Order>
com.iu.javadatastructureslab.services.ShopQueueService
Service for managing a priority-aware queue of shop orders.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new order to the queue with priority handling.booleancancelOrder(int orderId) Cancels an order by id and removes it from the queue if present.booleancompleteOrder(int orderId) Completes an order by id and stores it in the completed list.Returns the queue containing all pending orders.Returns the list of recently completed orders.Returns the currently processing order.Peeks at the next order without removing it.Dequeues and marks the next order as processing.Methods inherited from class com.iu.javadatastructureslab.services.QueueService
clear, dequeue, enqueue, getQueue
-
Constructor Details
-
ShopQueueService
public ShopQueueService()
-
-
Method Details
-
addOrder
Adds a new order to the queue with priority handling.- Parameters:
order- order to enqueue
-
processNextOrder
Dequeues and marks the next order as processing.- Returns:
- the order that is now processing, or null if empty
-
peekNextOrder
Peeks at the next order without removing it.- Returns:
- next order or null if the queue is empty
-
cancelOrder
public boolean cancelOrder(int orderId) Cancels an order by id and removes it from the queue if present.- Parameters:
orderId- order identifier- Returns:
- true if the order was found and canceled
-
completeOrder
public boolean completeOrder(int orderId) Completes an order by id and stores it in the completed list.- Parameters:
orderId- order identifier- Returns:
- true if the order was found and completed
-
getCurrentProcessingOrder
Returns the currently processing order.- Returns:
- current processing order, or null if none
-
getAllOrders
Returns the queue containing all pending orders.- Returns:
- queue of orders
-
getCompletedOrders
Returns the list of recently completed orders.- Returns:
- deque of completed orders
-