I finished from the program I have a problem to do the Excep

I finished from the program. I have a problem to do the Exception part. Is there expert who could help me??

7. Implement a Java generic queue class using the circular array algorithm that you used for implementing a C generic queue in Homework 5. Use an ArrayList rather than an array. We did not discuss this issue in class, but Java does not allow you to create generic arrays (e.g., items new EC101 is not allowed), which is why I am telling you to use an ArrayList. Your queue class should meet the following specifications: a. The API: You should implement the following API: i. Queue (int maxCapacity): maxCapacity is the maximum capacity of the queue. You will initialize your ArrayList to have maxCapacity elements ii. void enqueue(T value): Adds the value to the end of the queue iii. Tdequeue0: Removes the front value from the queue and returns it. iv. boolean isEmpty0: Returns true if the queue is empty and false otherwise. b. Exceptions: Your Queue class should throw two types of programmer-defined exceptions: i. queue overflow: if the maximum number of items in the queue is exceeded ii. empty queue: if the user attempts to dequeue an element from an empty queue. These exceptions should be thrown to the calling methods. c. Place your Queue class in a package called queue.

Solution

Hi Friend, You have not posted your code. So i can not give you complete running code.

But I am giving you all idea/concept that you can implement in your code.

Please let me know in case of any issue.

class QueueFullException extends Exception{

  

   public QueueFullException(String message) {

       super(message);

   }

}

class QueueEmptyException extends Exception{

  

   public QueueEmptyException(String message) {

       super(message);

   }

}

void enqueue(T value) throws QueueFullException{

  

   if( queue is full){

       throw new QueueFullException(\"queue full: can not enqueue \"+value);

   }

  

}

T dequeue() throws QueueEmptyException{

  

   if( queue is empty){

       throw new QueueEmptyException(\"queue empty: can not dequeue \");

   }

  

}

I finished from the program. I have a problem to do the Exception part. Is there expert who could help me?? 7. Implement a Java generic queue class using the ci
I finished from the program. I have a problem to do the Exception part. Is there expert who could help me?? 7. Implement a Java generic queue class using the ci

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site