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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!