Hello, I am helping my son with a college programming class, and I guess I need the class too. He has completed the assignment, but I don't believe he is doing it the best way. Unfortunately I can't get it to work with my better way. It's clearly better, because it doesn't work yet.
He is being asked to implement some methods for a class that extends another class.
He was told he must use the following class definition, and he cannot change anything in ListQueue.
public class MyListQueue <AnyType extends Comparable<AnyType>> extends ListQueue<AnyType>
Heres 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 feel pretty good about traversing a linked list in Pascal or C (showing my age) but have never worked in an OOP language before.
When I attempt something like this
dummyQueue = this.front.next;
I get the following error. * front has private access in ListQueue *
Which I agree with, but other than dequeueing an item, how can I traverse the list, or otherwise get access to front, back, next and previous which are all in ListQueue.
An education would be appreciated.
Thanks, David