Question: Write a class called LimitedQueue which implements a limited queue of Objects. The queue is a normal queue that accepts up to n elements only.

Write a class called LimitedQueue which implements a limited queue of Objects. The queue is a normal queue that accepts up to n elements only. Beyond the limit n of the queue, each additional item accepted will result in the removal of the oldest element in the queue. Include a constructor, add, remove, getLimit and size methods as defined here. constructor: must accept an int n which determines the limit of the queue add method: must accept an object to add to the end of the queue, after removing elements as needed. remove method: must remove the oldest object from the queue, and then return that element size method: must return the number of elements in the queue getLimit method: must return the maximum number of elements the queue will hold Important: Be sure that your constructor, add, remove, and size methods are public. Be sure that your queue accepts Objects
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
