1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#include <iostream>
#include <string>
using namespace std;
struct Pizza
{
string structSize;
string structTopping;
};
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 = -1; //generate default values of: Small (size), No topping (topping)
Pizza * pizzaPtr[2]; //2 different pizza orders
pizzaPtr[0]->structSize = "Small";
pizzaPtr[0]->structTopping = "No topping";
pizzaPtr[1]->structSize = "Small";
pizzaPtr[1]->structTopping = "No topping";
//******************************'Order' function call, to generate default values of: Small (size), None (topping)
Order(pizzaPtr, 0);
do {
cout << "Press 1, to see current selection. \n2, to change current selection. \n3, to end program: " << endl;
cin >> select;
switch (select)
{
case 1:
pizzaPtr[0];
cout << "Size of 1st pizza order: " << (*pizzaPtr)->structSize; //******************call initialization function to provide up to date information
cout << "Topping of 1st pizza order: " << (*pizzaPtr)->structTopping << endl;
pizzaPtr[1];
cout << "Size of 2nd pizza order: " << (*pizzaPtr)->structSize << endl;
cout << "Topping of 1st pizza order: " << (*pizzaPtr)->structTopping << endl;
break;
case 2:
cout << "Enter Pizza order #, you want to change: ";
cin >> pizzaOrder;
pizzaOrder -= 1; //passed on to Order( , int size)
cout << "\nEnter pizza size #" << pizzaOrder ;
getline(cin, pizzaPtr[pizzaOrder]->structSize);
cout << "\nEnter Pizza topping#: " << pizzaOrder;
getline(cin, pizzaPtr[pizzaOrder]->structTopping);
//********Should I or/ how do i pass these user data entries to Order function, so that
//when user enters 1 at the main menu, these values will appear for the book they wanted to edit
//Instead of the values; Size of 1st pizza order: small. Topping of 1st pizza order: no topping.
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)
{
//Dynamic array allocation required here
for (int i = 0; i == size; i++)
{
Pizza * setPtr; //call struct Pizza
setPtr = new Pizza[size];
cout << "\nEnter pizza size #" << size + 1 ;
getline(cin, setPtr[size].structSize);
cout << "\nEnter Pizza topping#: " << size + 1;
getline(cin, setPtr[size].structTopping);
}
//delete [] setPtr;
//setPtr = 0;
}
|