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
|
#include <iostream>
#include <string>
using namespace std;
// #include "PIZZA.cpp" // You supply this file
class Pizza;
class PizzaStore;
//=============================================================================================
//================Pizza Class==================================================================
class Pizza
{
public:
string name, address, topping; //declare variables name,address,topping,
Pizza *next_pizza;
//------------------------------------
Pizza(string n, string a, string t) //Pizza function
{ name = n; address = a; topping = t;}
string GetName() //GetName function
{ return name;}
string GetAddress() //GetAddress function
{ return address;}
string GetIngredients() //GetIngredients function
{ return topping;}
};
//=============================================================================================
//================PizzaStore Class=============================================================
class PizzaStore
{
private:
Pizza *First, *Last;
int counter;
//------------------------------------
public:
PizzaStore() //PizzaStore ***** CONSTRUCTOR ******
{
counter = 0;
First = NULL;
Last = NULL;
}
int PizzasWaiting() //PizzasWating function to return counter
{ return counter;}
//=============having trouble here================================
void Order(string n, string a, string t) //Order function
{
//cout << n << " " << a << " " << t << endl;
counter++;
/*---Having trouble below ---------------*/
Pizza *temp = new Pizza(n,a,t); //allocate memory to hold name,address, topping, & *new_pizza
temp->next_pizza=NULL; //set what ever temp points to, set next_pizza to NULL
if(First == NULL) //check to see if first is equal to NULL
{
First=temp; //First equal temp
}
else
{
Last->next_pizza= temp; //make the last pizza's next_pizza pointer point to where temp points
}Last = temp; //set last name equal to temp to stop when the last name is reached.
|