• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Storing Pizza Toppings Design

Guest
May 27, 2008 May 27, 2008

Copy link to clipboard

Copied

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?

Thanks
TOPICS
Advanced techniques

Views

270

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 27, 2008 May 27, 2008

Copy link to clipboard

Copied

LATEST
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.type="Pepperoni";
aTopping.location="2nd Half";
aTopping.price="1.95";

arrayAppend(aPizza.toppings,aTopping);

arrayAppend(MyCart,aPizza);


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation