Class ShopQueueService

java.lang.Object
com.iu.javadatastructureslab.services.QueueService<Order>
com.iu.javadatastructureslab.services.ShopQueueService

public class ShopQueueService extends QueueService<Order>
Service for managing a priority-aware queue of shop orders.
  • Constructor Details

    • ShopQueueService

      public ShopQueueService()
  • Method Details

    • addOrder

      public void addOrder(Order order)
      Adds a new order to the queue with priority handling.
      Parameters:
      order - order to enqueue
    • processNextOrder

      public Order processNextOrder()
      Dequeues and marks the next order as processing.
      Returns:
      the order that is now processing, or null if empty
    • peekNextOrder

      public Order 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

      public Order getCurrentProcessingOrder()
      Returns the currently processing order.
      Returns:
      current processing order, or null if none
    • getAllOrders

      public ArrayDeque<Order> getAllOrders()
      Returns the queue containing all pending orders.
      Returns:
      queue of orders
    • getCompletedOrders

      public ArrayDeque<Order> getCompletedOrders()
      Returns the list of recently completed orders.
      Returns:
      deque of completed orders