trouble with deques

So two things first off I am taking a data structures class so you cannot use the Standard Library at all none of the standard deque templates this is a purely array based program. Second thing is I do not want you to do my homework for me I am genuinely trying to understand why this isn't working. All of that being said I have it somewhat working on a FIFO basis it works just fine. but on a LIFO basis everything shifts improperly by exactly one. That and it crashes because I haven't set up the list function yet but I will get to that in a little bit. Here is my code. Here is the .h and .cpp files
#ifndef DEQUEUE_H
#define DEQUEUE_H
#include <string>

class dequeue
{
public:

//initialize array and other variables
int* Array;
int numElements;
int ArraySize;
int Left;
int Right;
int value;
static const int SIZE=100;
//dequeue constructor initializes one constructor to 100 elements
//initializes the other to size. also DESTRUCTOR.
dequeue();
dequeue(int n);
virtual ~dequeue();
//adds values to the left and right side of dequeue
void addLeft(int value);
void addRight(int value);
//sets array to zero to see where items are added
void zeroOut();
//removes and returns the left and right most elements
int getLeft();
int getRight();
//returns if the array is full or empty
bool isEmpty();
bool isFull();
//prints content of the array from ltr and rtl
std::string listRightLeft();
std::string listLeftRight();
//debug method that dumps the array from 0 to size -1
std::string dumpArray();

protected:

private:

};

#endif // DEQUEUE_H






#include "dequeue.h"
dequeue::dequeue()
{
Array= new int [SIZE];
ArraySize=SIZE;
numElements=0;
Left=Right=0;



}
dequeue::dequeue(int n)
{
Array= new int [n];
ArraySize=n;
numElements=0;
Left=Right=0;
}
dequeue::~dequeue()
{
delete[] Array;
}
void dequeue::addLeft(int value){

if(Left==ArraySize){
Left=0;

}
Array[Left]=value;
Left--;
}

void dequeue::addRight(int value){

if(Right==0){
Right=ArraySize-1;
}
Array[Right]=value;
Right++;
}

int dequeue::getLeft(){
Left++;
if(Left==ArraySize){
Left=0;
}
return Array[Left];
}

int dequeue::getRight(){
Right--;
if(Right==0){
Right=ArraySize-1;
}

return Array[Right];
}
bool dequeue::isEmpty(){
return numElements==0;
}

bool dequeue::isFull(){
return numElements==ArraySize;
}

std::string dequeue::listRightLeft(){
std::string thing;
return thing;}
std::string dequeue::listLeftRight(){std::string thing;
return thing;}

//std::string dequeue::dumpArray(){}

Thanks for taking a look
First, I don't recommend this kind queue;
Second, you should modify numElements when adding element;
Third, in function addLeft and addRight, I don't understand the judgement of left, right and ArraySize. Try addRight several times, you will see the problem.
I think the key problem is two if statements in addLeft and addRight.
Topic archived. No new replies allowed.