Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I keep getting this error. Could you help me with it? Thanks! public static final class LinkedQueue implements QueueInterface { private Node firstNode; private Node

I keep getting this error. Could you help me with it? Thanks!

image text in transcribed

public static final class LinkedQueue implements QueueInterface { private Node firstNode; private Node lastNode;

public LinkedQueue() { firstNode = null; lastNode = null; }

@Override public T getFront() { if (isEmpty()) { return null; } return firstNode.getData(); }

@Override public boolean isEmpty() { return firstNode == null; }

@Override public void clear() { firstNode = null; lastNode = null;

}

public class Node { private E data; // Entry in bag private Node next; // Link to next node

public Node(E dataPortion) { this(dataPortion, null); } // end constructor

public Node(E dataPortion, Node nextNode) { data = dataPortion; next = nextNode; } // end constructor

public E getData() { if (data != null) { return data; } return null; }

public Node getNext() { return next; }

public void setNext(Node newNext) { next = newNext; }

} // end LinkedQueue

2.0 / 3.0 Result Behavior 1/** 2 @precondition: queue is not empty 3 @return value from removed node that was at the front of the queue 4 5@Override 6 public T dequeue() { 7 if (isEmpty()) return null; 9 I frontValue = getFront(); 10 firstNode.setData(null); 11 firstNode = firstNode.getNext(); 12 Dequeue updates first node Dequeue updates properly when empty Expected: but was: Dequeue updates properly when not empty 13 14 return frontValue; 15 16]} 17

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions