I help my son with a programming class in college, and I think I need a class too. He completed the task, but I do not think that he is doing it in the best way. Unfortunately, I can't get it to work with my best way. This is clearly better because it is not working yet.
He is invited to implement some methods for a class that extends another class.
He was told that he should use the following class definition, and he could not change anything in ListQueue.
public class MyListQueue <AnyType extends Comparable<AnyType>> extends ListQueue<AnyType>
Here is what is in ListQueue
// Queue interface // // ******************PUBLIC OPERATIONS********************* // void enqueue( x ) --> Insert x // AnyType getFront( ) --> Return least recently inserted item // AnyType dequeue( ) --> Return and remove least recent item // boolean isEmpty( ) --> Return true if empty; else false // void makeEmpty( ) --> Remove all items // ******************ERRORS******************************** // getFront or dequeue on empty queue /** * Protocol for queues. */
OK. I am very good at navigating a linked list to Pascal or C (showing my age), but I have never worked in OOP before.
When I try something like this
dummyQueue = this.front.next;
I get the following error. * front has personal access to ListQueue *
I agree with this, but I am not deleting the object, how can I cross the list or otherwise access the front, back, next and previous, which are all in ListQueue.
Education will be appreciated.
Thanks David
user224938
source share