Hi, i have this assignment to do and i dont really know what i have to do

could someone tell me what i have to do in simpler language

thanks

Here is the assignment:


Create a program which:
Implements a class called Queue: The class should contain an array of maxQ integers.
There should be two constructors:
One that takes no argument creates a Queue object of maxQ=100 values.
One that takes a parameter q and creates a Queue object of maxQ=q values.
Queue should also have:
a function/method add(int) by which a user can add an integer value to a Queue object.
a function/method take() by which a user can read from a Queue object the first integer that was entered into it. After being read the integer should not be in the queue anymore.
In the main():
create a Queue object of maxQ=20
keep on asking the user whether (s)he wants to 1) add integers to the queue; 2) take integers from the queue; 3) exit.
when the user is prompted for the choice above (s)he should also be shown how many integers are currently in the queue.

Suggestions:
You may have 2 values stored inside class Queue:
start: the position of the first element that was entered
end: the position of the last element entered
When an element is added through add(int), end should advance by one. If this brings it past the end of the array, it should pan to the beginning.
When an element is taken through take():
if no element is in the queue, 0 should be returned and nothing else should happen
if the queue is not empty, the first element entered (the one at position start) should be returned, and start should advance by one. If this brings it past the end of the array, it should pan to the beginning.

thanks.

Fill this in:

class Queue {
  //what goes here?
};

Then, instantiate it in your main() and manipulate it accordingly.

Edited 6 Years Ago by Fbody: n/a

i think i get what i have to do, apart from the two constructors.

It seems to me that the first constructor doesnt get used at all in the main.

True, you'll probably only use the second constructor (commonly called a "specified" or "overloaded" constructor). But, it's good practice to provide a "default" constructor as well because of how the compiler works. If you don't, it can lead to some serious headaches down the road.

Actually, you should provide a "copy constructor" as well, but you're not going to use it and you're not required to by the assignment.

Edited 6 Years Ago by Fbody: n/a

This question has already been answered. Start a new discussion instead.