Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

P ROJECT D ESCRIPTION A VipQueueis a regular queue enhanced with an additional e

ID: 3673310 • Letter: P

Question

PROJECT DESCRIPTION

A VipQueueis a regular queue enhanced with an additional enqueue operation called anvipEnqueue, which allows an item to be added to the front of the queue. The following “main” class illustrates the use of a VipQueue of integers:

public class Tester {

public static void main(String args[]){

VipQueue<Integer>vq= newVipQueue<Integer>(10);

for (inti=0; i<5;i++){

if (!vq.isFull()) vq.enqueue((Integer)i);      //a "regular" enqueue

if (!vq.isFull()) vq.vipEnqueue((Integer)(i*i));        //a vipenqueue

} while (!vq.isEmpty()) System.out.printf("->%d", vq.dequeue());

}

}

Executing the code above should yield output that looks like this:

->16->9->4->1->0->0->1->2->3->4

For this assignment you are to implement a VipQueueclass that supports the operations illustrated in the Tester class above. This is how you should proceed.

Implement a Stack class that supports the operations in Appendix A. This Stack should be implemented as a linked list.

Implement a Queue class that supports the operations in Appendix A. This Queue should be implemented as an array.

Implement your VipQueueclass such that each VipQueueobject is represented as a single Stack object and a single Queue object. That is, the only data members of your VipQueueclass should be one Stack, one Queue, and perhaps some constant number of additional primitive variables (integers, booleans, etc.).

You may assume that the enqueueand vipEnqueuemethods have the precondition that the vipQueue not be full, and that your dequeueoperation has the precondition that the vipQueue not be empty.

NOTE

Do not use any in-built Java implementation (e.g., Stack, Queue, Lists, ArrayList, etc) from the java.util.* API. You must implement the above from scratch.

GRADING RUBRIC

(15 points) Stack correctly implemented using a linked list

(15 points) Queue correctly implemented using an array

(10 points) Use of generics

(15 points) VipQueueenqueuemethod implementation

(15 points) VipQueuevipEnqueuemethod implementation

(20 points) Other VipQueue methods

(10 points) Clean code

2

SUBMISSION INSTRUCTIONS

Upload all your source code in a .zip file to BB and bring me a hard copy of your source code and output runs on the due date. You are responsible for ensuring that your program compiles and functions properly. Any non-functioning program will receive a zero.

APPENDIX A: REQUIRED METHODS

Your Stack class should support the following constructor and operations (T is a generic type):

public Stack(int capacity)

publicbooleanisEmpty()

publicbooleanisFull()

public T peek()

public T pop()

public void push(T element)

Your Queue class should support the following constructor and operations (T is a generic type):

public Queue(int capacity)

publicbooleanisEmpty() public booleanisFull()

public T peek()

public T dequeue()

public void enqueue(T element)

Your VipQueueclass should support the following constructor and operations (T is a generic type):

publicVipQueue(int capacity)

publicbooleanisEmpty()

publicbooleanisFull()

public T peek()

public T dequeue()

public void enqueue(T element)

public void vipEnqueue(Telement)

Explanation / Answer

////////////////////////////////////////////// VipQueue.java////////////////////////////////////////

/////////////////////////////////////////////////////// Stack.java /////////////////////////////////////////////

/////////////////////////////////////////////////// Queue.java //////////////////////////////////////////

//////////////////////////////////////////// test.java ////////////////////////////////////////////

////////////////////////////////////////////   test2.java ////////////////////////////////////////////