public HawaiianPizza(PizzaBuilder builder) { this.mPrice = builder.Price; this.mIsFamilySize = builder.IsFamilySize; this.mHasCheese = builder.HasCheese; this.mNumCheese = builder.NumCheese; this.mHasHam = builder.HasHam; this.mNumHam = builder.NumHam; this.mHasOnion = builder.HasOnion; this.mNumOnion = builder.NumOnion; this.mHasPineapple = builder.HasPineapple; this.mNumPineapple = builder.NumPineapple; this.mHasSalami = builder.HasSalami; this.mNumSalami = builder.NumSalami; }
private Pizza OrderPizza() { PizzaBuilder pizzaBuilder = new PizzaBuilder(); int choice = -1; Console.WriteLine("What pizza would you like?"); Console.WriteLine("1. Pizza Margherita (tomato, cheese) 4.99$"); Console.WriteLine("2. Hawaiian Pizza (tomato, cheese, ham, pineapple) 6.49$"); Console.WriteLine("3. Salami Pizza (tomato, cheese, salami) 5.99$"); while (choice < 0 || choice > 3) { Console.Write("Your pizza choice: "); try { choice = Int16.Parse(Console.ReadLine()); } catch (FormatException e) { Console.WriteLine("Invalid choice!"); } } switch (choice) { case 2: pizzaBuilder.AddHam(); pizzaBuilder.AddPineapple(); break; case 3: pizzaBuilder.AddSalami(); break; default: break; } choice = -1; Console.WriteLine("Would you like to add toppings?"); Console.WriteLine("Notice: Depend on toppings, your pizza can change to another to save money!"); Console.WriteLine("1. Cheese 0.69$"); Console.WriteLine("2. Ham 0.99$"); Console.WriteLine("3. Onion 0.69$"); Console.WriteLine("4. Pineapple 0.79$"); Console.WriteLine("5. Salami 0.99$"); Console.WriteLine("6. Done!"); while (choice != 6) { Console.Write("Your topping choice: "); try { choice = Int16.Parse(Console.ReadLine()); } catch (FormatException e) { choice = -1; } switch (choice) { case 1: pizzaBuilder.AddCheese(); break; case 2: pizzaBuilder.AddHam(); break; case 3: pizzaBuilder.AddOnion(); break; case 4: pizzaBuilder.AddPineapple(); break; case 5: pizzaBuilder.AddSalami(); break; case 6: break; default: Console.WriteLine("Your choice is not in menu!"); break; } } Console.Write("Would you like family size? (Y for yes, any key for no) "); string isFamily = Console.ReadLine(); if (isFamily.ToLower().CompareTo("y") == 0) { pizzaBuilder.IsFamilySize = true; } return(pizzaBuilder.Build()); }