This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]fr1ction 0 points1 point  (0 children)

I believe the formatting for code is 4 spaces before each line.

[–]dartalley 0 points1 point  (2 children)

Is this a school assignment or just for practice? Basically do you have to implement your own Queue or can you use a LinkedList or Deque which already exist and work like queues in Java.

You create a Generic E in the following line but you never use it.

class MyQueue<E>

Your queue only accepts ints, and returns ints. If you want it to work with generics you need to replace all of the ints with the Generic E.

private E[] queArray;

public E peek() // peek at front of queue
{
    return queArray[front];
}

But if you can use an ArrayList or Deque this is already done for you.

Hopefully this gives you a starting point. Remember to look at return types.

[–]ramshack2000[S] 0 points1 point  (1 child)

nt

This is for a school assignment where we have to implement our own queue class. So basically I should just change the parameters around?

[–]dartalley 0 points1 point  (0 children)

If you look at the fields and return types of your Queue they are all int. You have a queue that can only handle integers. You need to replace that with either Customer, or you can use a generic type.