Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started