1 Reply Latest reply on May 27, 2008 2:08 PM by Newsgroup_User

    Storing Pizza Toppings Design

      Hey everyone,

      I am designing a shopping cart for a pizza store and I can store regular items that have no customization like a drink, pasta dish, etc. I am stoing this using the usual arrays and structures in which I have the structures holding the ProductID, Price, Quantity, etc. But now for a pizza the trouble I am having is when a customer order a Pizza they need to be able to customize:

      Toppings and how they would like the toppings like Half, Full, Double, etc. I will give an example below but I can't quite get my head around how to store such a thing.

      For example user clicks on the Pizza they want to order and they get these choices via checkboxes:

      Pizza with Cheese:

      Pepperoni : (NONE, 1st HALF, 2nd HALF, FULL, DOUBLE)
      Sausage : (NONE,1st HALF, 2nd HALF, FULL, DOUBLE)
      Extra Cheese : (NONE,1st HALF, 2nd HALF, FULL, DOUBLE)
      Mushrooms : (NONE,1st HALF, 2nd HALF, FULL, DOUBLE)

      Now before my array and structure is built to handle storing the like Pizza with Cheese, Quantity, Price but this kind of customization I am not sure how will I store what each pizza has.

      I am using this example sample that I saw for CDs:

      MyCart = ArrayNew(1);

      OneCD = StructNew();
      OneCD.Title = "Cookin at the Plugged Nickel";
      OneCD.Artist = "Miles Davis";
      OneCD.Genre = "Jazz";
      OneCD.Cost = "15.00";
      OneCD.Quantity = "1";

      AddIt = ArrayAppend(MyCart, OneCD);

      AnotherCD = StructNew();
      AnotherCD.Title = "Lady in Satin";
      AnotherCD.Atrist = "Billie Holiday";
      AnotherCD.Genre = "Blues";
      AnotherCD.Cost = "14.00";
      AnotherCD.Quantity = "2";

      AddIt = ArrayAppend(MyCart, AnotherCD);

      So the question is really what do I use as the StructKey? is it the topping itself like Pepperoni or is it more like the Type like 1st HALF, 2nd HALF, FULL?

        • 1. Re: Storing Pizza Toppings Design
          Level 7
          yaf23 wrote:

          This really screams of an object with methods and properties that can
          truly handle this type of complex data. But if your assignment is to
          use structures, you are going to need some type of nested affair.

          Here is an example that may get you started. This is just one crude way
          that demonstrates how one can nest complex structures to great affect.

          aPizza = structNew();
          aPizza.toppings = arrayNew(1);

          aTopping = structNew();
          aTopping.location="2nd Half";