hi guys i would like to get some brief explanation for these functions. I don't have a good vision on this code. so kindly guys can please..please :) give some help
You are trying to understand a incomplete piece of code here. Where is the definition of class SandwichQueue or Order. In their definition there should be what you are looking for. You are using member function for both but I can't tell what they do since no code is shown. Where is the rest?
it needs to complete those three functions.
Order pop();
void push(const Order& sandwich);
void expandQ();
I did some of code but i'm not sure abot them
#include <iostream>
#include <sstream>
usingnamespace std;
constint initialSize = 5;
struct Order {
string sandwich;
string customerName;
int orderNbr;
bool fries;
};
class SandwichQueue{
public:
SandwichQueue();
//Interface for queue
Order pop();
void push(const Order& sandwich);
void expandQ();
bool isEmpty();
int size();
private:
//qSize is size of array, not amount stored in queue
int qSize;
Order* orderQ;
int front;
int back;
};
int main()
{
SandwichQueue sQ;
Order testCases[15];
Order temp;
string s = "sandwich";
string c = "customer";
for(int i = 0; i < 15; i++)
{
testCases[i].sandwich = s;
testCases[i].customerName = c;
testCases[i].orderNbr = i;
testCases[i].fries = i%2;
}
//a few tests...
//add one
sQ.push(testCases[0]);
//remove one
testCases[0] = sQ.pop();
//Next test wrap around
for(int i = 0; i < 3; i++) // explain
{
sQ.push(testCases[i]);
sQ.push(testCases[i]);
temp = sQ.pop();
}
//test undrflow
for(int i = 0; i < 11; i++)
{
if(!sQ.isEmpty())
temp = sQ.pop();
else
cout << "Q empty - no more sandwiches" << endl;
}
//test overflow
for(int i = 0; i < 15; i++)
{
sQ.push(testCases[i]);
}
}
SandwichQueue::SandwichQueue()
{
qSize = initialSize;
orderQ = new Order[initialSize];
back = qSize - 1;
front = 0;
}
bool SandwichQueue::isEmpty()
{
if (size() == 0)
returntrue;
elsereturnfalse;
}
int SandwichQueue::size()
{
return (back - front + 1 + qSize) % qSize;
}
//function to pop
Order SandwichQueue::pop()
{
if (!SQ.isempty())
SQ.pop();
elsereturn temp;
}
//push an element, make sure it is not full, if it is call expand funciton
void SandwichQueue::push(const Order& sw)
{
}
//Double the queue size, copy the values, and reset back and front
void SandwichQueue::expandQ()
{
for(testcases[i]> size)
}
//function to pop
Order SandwichQueue::pop()
{
if (!SQ.isempty())
SQ.pop();
elsereturn temp;
}
//push an element, make sure it is not full, if it is call expand funciton
void SandwichQueue::push(const Order& sw)
{
}
//Double the queue size, copy the values, and reset back and front
void SandwichQueue::expandQ()
{
if(testcases[i]> size())
}