My primary objective right now is to get the program to display the following, when the user presses 1 at the main menu:
Size of 1st pizza order: Small
Topping of 1st pizza order: No topping
Size of 2nd pizza order: Small
Topping of 2nd pizza order: No topping
I think the main culprit is the Order function; but trust me, i've tried several different combination/orders of the statement.
#include <iostream>
#include <string>
using namespace std;
struct Pizza
{
string structSize;
string structTopping;
//string pizzaRAY[2]; //2 different pizza orders
};
void Order(Pizza * specPtr[], int size);
int main()
{
int select, size; //size will refer to the title group user wants to view/modify
string pizzaSize, pizzaTopping;
int pizzaOrder; //generate default values of: Small (size), No topping (topping)
//Pizza * pizzaPtr[2]; //2 different pizza orders
Pizza * pizzaPtr[2];
Pizza setup1, *setup2;
Order(pizzaPtr, -2);
do {
cout << "\n1, to see current selection. \n2, to change current selection. \n3, to end program: " << endl;
cin >> select;
switch (select)
{
case 1:
pizzaPtr[0] = new Pizza;
cout << "Size of 1st pizza order: " << pizzaPtr[0]->structSize ;
cout << "\nTopping of 1st pizza order: " << pizzaPtr[0]-> structTopping << endl;
pizzaPtr[1] = new Pizza;
cout << "Size of 2nd pizza order: " << pizzaPtr[1]->structSize ;
cout << "\nTopping of 2nd pizza order: " << pizzaPtr[1]->structTopping << endl;
break;
case 2:
cout << "Enter Pizza order #, you want to change: ";
cin >> pizzaOrder;
//pizzaOrder -= 1; //passed on to Order( , int size)
Order(pizzaPtr, pizzaOrder);
break;
case 3:
cout << "Thank you for using this program" << endl;
break;
}
} while (select != 3);
system("pause");
return 0;
}
void Order(Pizza * specPtr[], int size)
{
for (int i = 0; i < size; i++)
{
Pizza * setPtr; //call struct Pizza
setPtr = new Pizza[size];
Pizza *ptr = &setPtr[0];
/*if (size < 0)
{
}
else
{ */
int min;
min = size - 1;
if (i == min)
{
cout << "\nEnter size of of piza: " ;//<< specPtr[size]->structSize;
cin.ignore();
getline(cin, (setPtr[i]).structSize);
cout << "\Enter topping of piza: " ;// << specPtr[size]->structTopping;
cin.ignore();
getline(cin, (setPtr[i]).structTopping);
cout << endl;
}
else
{
setPtr[0].structSize = "Small";
setPtr[0].structTopping = "No topping";
setPtr[1].structSize = "Small";
setPtr[1].structTopping = "No topping";
}
delete [] setPtr;
}
}