The first code which has a class in which I tried implementi
The first code which has a class in which I tried implementing the main methods needed for aproper queue. Unfortunately, I did not get it to work. I left the store field protected, so you should be able to directly access it from another class in the edu.buffalo.cse116 package. I also wrote the EmptyQueueException class for you to use. Write a JUnit test class whose methods call the enqueue(), dequeue(), or peek() method and verify they correctly updatestoreand fix the bugs in this class.
first code:
EmptyQueueException class
Solution
public void deQueue(final int queueNo) {
 
 if (planeNode != null && this.getSize() > 1) {//check if queue size is not equal to null and queue size must be greater than 1
 int index = 0;
 PlaneNode currentNode = planeNode;// assign first node as current node
 
 if (index + 1 == queueNo) {// compare the queue position of the current node is equal to the param queue position
 planeNode = planeNode.getNext();// if it is get the 2nd node and assign as first node
 planeNode.setPrevious(null);//set previous node of the first node to null
 } else {//not in the first node
 
 while (currentNode.getNext() != null) {//While the next node is not empty
 index++;//increment node count x 1
 currentNode = currentNode.getNext();// assign the 2nd node as current node
 
 
 if (index + 1 == queueNo) {// compare the queue position of the current node and see if it is equal to the current param queue position
 PlaneNode previousNode = currentNode.getPrevious();// if it is get the previous node of the current node
 PlaneNode nextNode = currentNode.getNext();// get the next node before the current node and make it the current node
 
 previousNode.setNext(nextNode);// assign nextNode of the current node to the nextNode of previous node of the current node
 if (nextNode != null) {
 nextNode.setPrevious(previousNode);//assign previous node of the current node to previousNode of the nextNode of the current node
 }
 }
 }
 }
 } else {
 planeNode = null;// assign null to queue if node is equal to null or queue size is 1
 }
 }
 public void enQueue(String aircraftNum, String airline, String departCity, int passengers) {
 
 PlaneNode newPlaneNode = new PlaneNode(aircraftNum, airline, departCity, passengers, null, null);//creates a new planeNode object i.e. the first or next object
 if (planeNode != null) {// check if queue is not empty
 
 PlaneNode lastPlaneNode = getLastNode();// get last node in the queue and assign to another PlaneNode object
 insert(lastPlaneNode, newPlaneNode);//call insert method and pass lastPlaneNode object and newPlaneNode object
 
 } else {
 planeNode = newPlaneNode;// assign new PlaneNode object as first node of the queue
 }
 }
 }
 
 /**
 * Test of enQueue method, of class IFMQueue.
 */
 @Test
 public void testEnQueue() {
 System.out.println(\"enQueue\");
 String aircraftNum = \"\";
 String airline = \"\";
 String departCity = \"\";
 int passengers = 0;
 IFMQueue instance = new IFMQueue();
 instance.enQueue(aircraftNum, airline, departCity, passengers);
 // TODO review the generated test code and remove the default call to fail.
 fail(\"The test case is a prototype.\");
 }
 }
 
 /**
 * Test of enQueue method, of class IFMQueue.
 */
 @Test
 public void testEnQueue() {
 System.out.println();
 System.out.println(\"________________________________________________________________________________________\");
  System.out.println(\"Testing the enQueue method within the IFMQueue class \");
 System.out.println(\"Current Queue Size \" + q.getSize());
 System.out.println(\"Now adding the following 3 plane objects to the queue\  \");
 System.out.println();
 
 q.enQueue(BA100);
 System.out.println(BA100);
 q.enQueue(BA200);
 System.out.println(BA200);
 q.enQueue(BA300);
 System.out.println(BA300);
 
 System.out.println();
 System.out.println(\"The size of the queue is currently \" + q.getSize() + \" - Now calling view all method\ \");
 q.viewAll();
 
 int expected = 3;
 int equals = q.getSize();
 
 System.out.println();
 System.out.println(\"Queue size = \" + q.getSize());
 System.out.println();
 assertEquals(expected, equals);
 System.out.println();
 }
 }
 /**
 * Test of deQueue method, of class IFMQueue. As this method does not return
 * anything I will populate a queue with three planes using the enQueue
 * method and display these planes with the viewAll method. I will then
 * deQueue one of the planes and initiate the viewAll method to show that
 * the plane object has been removed.
 *
 * Assert equals will be satisfied using the getSize (queue size/length)
 * method from before and after
 */
 @Test
 public void testDeQueue() {
 System.out.println();
 System.out.println(\"Testing the deQueue method within the IFMQueue class \");
 System.out.println(\"Current Queue Size \" + q.getSize());
 System.out.println(\"Now adding the following 3 plane objects to the queue\  \");
 System.out.println();
 
 q.enQueue(BA100);
 System.out.println(BA100);
 q.enQueue(BA200);
 System.out.println(BA200);
 q.enQueue(BA300);
 System.out.println(BA300);
 
 System.out.println();
 System.out.println(\"The size of the queue is currently \" + q.getSize() + \" - Now calling viewAll method\ \");
 q.viewAll();
 
 System.out.println(\"deQueue method will now remove a Plane object/node 1 from the queue and re-shuffle objects \");
 q.deQueue(1);
 System.out.println(\"Calling viewAll method\  \");
 q.viewAll();
 int expected = 2;
 int equals = q.getSize();
 System.out.println(\"Queue size is now \" + q.getSize());
 assertEquals(expected, equals);
 System.out.println(\"________________________________________________________________________________________\");
  System.out.println();
 }
 public class QueueTester {
   private AwesomeQueue queue;
   
    @Before
    //this method will be run before each \'@Test\' due to the \'@Before\' annotation.
    //use it to initialize data structures, and other things you need to do before each test
    public void init()
    {
        queue=new AwesomeQueue();
    }
   
    @Test
    //the \'@Test\' annotation marks it as, surprisingly enough, a test.
    //each test will be run independently
    public void testIsEmptyOnEmpty() {
        assertTrue(queue.isEmpty());
    }
   
    @Test
    public void testIsEmptyOnNotEmpty() {
        queue.enqueue(5);
        assertTrue(!queue.isEmpty());
    }
   
    @Test
    public void testOneEnqueue() {
        queue.enqueue(5);
    }
   
    @Test
    public void testOneDequeue() {
        queue.enqueue(5);
        assertTrue(5==queue.dequeue());
    }
   
    @Test
    public void testOrdering() {
        queue.enqueue(1);
        queue.enqueue(2);
        queue.enqueue(3);
        assertEquals(1,queue.dequeue());
        assertEquals(2,queue.dequeue());
        assertEquals(3,queue.dequeue());
    }
   
    @Test(expected=NoSuchElementException.class)
    public void testDequeueOnEmpty() {
        queue.dequeue();
    }
   
    @Test
    //this checks to make sure that enqueueing then dequeueing doesn\'t break isEmpty()
    public void testEmptyAfterDequeue() {
        queue.enqueue(5);
        queue.dequeue();
        assertTrue(queue.isEmpty());
    }
   
    @Ignore
    //you can use the \'@Ignore\' annotation to effectively hide a test
    public void ignoreMe()
    {
        throw new RuntimeException(\"Error\");
    }
   
    //you can, of course, declare other methods besides tests; just exclude the \'@Test\'.
    //This one gets used by several tests that call it with different arguments.
    //this performs n random operations on an AwesomeQueue and java\'s LinkedList, and verifies that they end up the same.
    //this is useful for testing because 1) it can test for very large examples and 2) it tests enqueues and dequeues in all sorts of interleaved orderings, possibly picking out obscure bugs
    //Note: this uses random values, which means that running tests different times could have different results (if, say, there is a bug in your code but hitting it is rare)
    private void testNOperations(int n)
    {
        Random r=new Random();
        LinkedList<Integer> goodQueue=new LinkedList<Integer>();
        int num;
        for(int i=0;i<n;i++)
        {
            //enqueue element if queue is empty, or on a 2/3 chance
            if(queue.isEmpty() || r.nextInt(3)<2)
            {
                num=r.nextInt(100);
                queue.enqueue(num);
                goodQueue.add(num);
            }
            else //dequeue
            {
                assertTrue(\"Queues differ on dequeue\",goodQueue.remove()==queue.dequeue());
            }
            //using different asserts, such as assertEquals, can clarify your intent to people reading your code
            //technically, when using assertEquals, you\'re supposed to put the expected value first, then the actual value
            assertEquals(\"goodQueue and queue do not match on isEmpty()\",goodQueue.isEmpty(),queue.isEmpty());
        }
       
        //now that we\'re done going through n operations, dequeue until empty and compare results
        while(!queue.isEmpty())
        {
            assertTrue(\"goodQueue is empty but queue isn\'t\",!goodQueue.isEmpty());
            assertTrue(\"End dequeues do not match\",goodQueue.remove()==queue.dequeue());
        }
        assertTrue(\"queue is empty but goodQueue isn\'t\",goodQueue.isEmpty());
    }
   
    @Test
    public void test10()
    {
        testNOperations(10);
    }
   
    @Test
    public void test100()
    {
        testNOperations(100);
    }
   
    @Test
    public void test10000()
    {
        testNOperations(10000);
    }
   
    @Test
    public void testMillion()
    {
        testNOperations(1000000);
    }
 }





