Exemplo n.º 1
0
 public static PizzaRestaurant getInstance()
 {
     if (instance == null)
     {
         instance = new PizzaRestaurant();
     }
     return(instance);
 }
Exemplo n.º 2
0
 public QuattroFormaggi() : base(400, new ArrayList(), 20.5f)
 {
     ingredients.Add("Gorgonzola");
     ingredients.Add("Blue Cheese");
     ingredients.Add("Parmesan");
     if (typeof(SundayStrategy).IsInstanceOfType(PizzaRestaurant.getInstance().getOffer()))
     {
         price = price * 0.25f;
     }
 }
Exemplo n.º 3
0
 public Pizza(int quantity, ArrayList ingredients, float price)
 {
     this.quantity    = quantity;
     this.ingredients = ingredients;
     this.ingredients.Add("Mozzarella");
     this.ingredients.Add("Tomato Sauce");
     if (typeof(OddDaysStrategy).IsInstanceOfType(PizzaRestaurant.getInstance().getOffer()))
     {
         price = price / 2;
     }
     this.price = price;
 }
Exemplo n.º 4
0
        private void staggioniCounter_ValueChanged(object sender, EventArgs e)
        {
            int temp = (int)staggioniCounter.Value;

            if (typeof(EvenDaysStrategy).IsInstanceOfType(PizzaRestaurant.getInstance().getOffer()))
            {
                if (temp % 3 == 0)
                {
                    temp--;
                }
            }
            totalPrice = margheritaCost * (int)margheritaCounter.Value + staggioniCost * temp +
                         carnivoraCost * (int)carnivoraCounter.Value + formaggiCost * (int)formaggiCounter.Value;
            costBox.Text = totalPrice.ToString();
        }
Exemplo n.º 5
0
 public MenuForm(String name, float balance, AuthenticationForm parentForm)
 {
     this.parentForm = parentForm;
     client          = new Client(name, balance);
     InitializeComponent();
     balanceBox.Text      = balance.ToString();
     nameBox.Text         = name;
     domino               = PizzaRestaurant.getInstance();
     margheritaCost       = domino.pizzaFactory("Margherita").getPrice();
     carnivoraCost        = domino.pizzaFactory("Carnivora").getPrice();
     staggioniCost        = domino.pizzaFactory("QuattroStaggioni").getPrice();
     formaggiCost         = domino.pizzaFactory("QuattroFormaggi").getPrice();
     margheritaPrice.Text = margheritaCost.ToString();
     carnivoraPrice.Text  = carnivoraCost.ToString();
     staggioniPrice.Text  = staggioniCost.ToString();
     formaggiPrice.Text   = formaggiCost.ToString();
     offerBox.Text        = domino.getOffer().generateOffer().show();
 }
        public void ReturnExpectedApprovals_WhenProcessOrdersIsCalled()
        {
            var expectedApprovals = new List <string>
            {
                "Approved by Rob",
                "Approved by John",
                "Requires Board Meeting",
                "Approved by Roberto"
            };
            var orderTotals     = new[] { 1000, 150, 5000, 50 };
            var headChef        = new HeadChef("Roberto");
            var kitchenManager  = new KitchenManager("John");
            var generalManager  = new GeneralManager("Rob");
            var pizzaRestaurant = new PizzaRestaurant(headChef, kitchenManager, generalManager);

            var approvals = pizzaRestaurant.ProcessOrders(orderTotals);

            approvals.Should().BeEquivalentTo(expectedApprovals);
        }
        public void ReturnFullRestaurantHierarchy_WhenGetHierarchyIsCalled()
        {
            var expectedHeadChef       = "Adrian";
            var expectedKitchenManager = "David";
            var expectedGeneralManager = "Yuliya";
            var expectedHierarchy      = new List <Tuple <string, Type> >
            {
                new Tuple <string, Type>(expectedHeadChef, typeof(HeadChef)),
                new Tuple <string, Type>(expectedKitchenManager, typeof(KitchenManager)),
                new Tuple <string, Type>(expectedGeneralManager, typeof(GeneralManager))
            };
            var headChef        = new HeadChef(expectedHeadChef);
            var kitchenManager  = new KitchenManager(expectedKitchenManager);
            var generalManager  = new GeneralManager(expectedGeneralManager);
            var pizzaRestaurant = new PizzaRestaurant(headChef, kitchenManager, generalManager);

            var restaurantHierarchy = pizzaRestaurant.GetHierarchy();

            restaurantHierarchy.Should().BeEquivalentTo(expectedHierarchy);
        }
Exemplo n.º 8
0
            public void confirmOrder()
            {
                float total             = 0;
                int   margheritaCounter = 0;
                int   carnivoraCounter  = 0;
                int   staggioniCounter  = 0;
                int   formaggiCounter   = 0;
                int   offerCheck        = 0;

                for (int i = 0; i < orders.Count; i++)
                {
                    Pizza pizza = (Pizza)orders[i];
                    if (typeof(OddDaysStrategy).IsInstanceOfType(PizzaRestaurant.getInstance().getOffer()))
                    {
                        total += (pizza.getPrice() / 2);
                    }
                    else if (typeof(EvenDaysStrategy).IsInstanceOfType(PizzaRestaurant.getInstance().getOffer()))
                    {
                        if (typeof(Margherita).IsInstanceOfType(pizza))
                        {
                            margheritaCounter++;
                            offerCheck = margheritaCounter;
                        }
                        else if (typeof(Carnivora).IsInstanceOfType(pizza))
                        {
                            carnivoraCounter++;
                            offerCheck = carnivoraCounter;
                        }
                        else if (typeof(QuattroFormaggi).IsInstanceOfType(pizza))
                        {
                            formaggiCounter++;
                            offerCheck = formaggiCounter;
                        }
                        else if (typeof(QuattroStaggioni).IsInstanceOfType(pizza))
                        {
                            staggioniCounter++;
                            offerCheck = staggioniCounter;
                        }
                        if (offerCheck % 3 != 0)
                        {
                            total += pizza.getPrice();
                        }
                    }
                    else
                    {
                        if (typeof(QuattroFormaggi).IsInstanceOfType(pizza))
                        {
                            total += (pizza.getPrice() * 0.25f);
                        }
                    }
                }
                if (total > balance)
                {
                    MessageBox.Show("Insufficient funds!");
                }
                else
                {
                    balance -= total;
                    MessageBox.Show("Thank you for your purchase!\nHere is your change" + " " + balance);
                }
            }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            List <Step> pancakeSteps = new List <Step>
            {
                new Step {
                    Definition = "Put all ingredients into a bowl", Duration = 2, Cost = 2.33M
                },
                new Step {
                    Definition = "Mix ingredients", Duration = 10, Cost = 1.25M
                },
                new Step {
                    Definition = "Heat pan", Duration = 5, Cost = 0.5M
                }
            };

            List <Step> pizzaSteps = new List <Step>
            {
                new Step {
                    Definition = "Add tomato sauce", Duration = 2, Cost = 0.59M
                },
                new Step {
                    Definition = "Add cheese", Duration = 2, Cost = 1.21M
                },
                new Step {
                    Definition = "Add spices", Duration = 2, Cost = 0.58M
                },
                new Step {
                    Definition = "Add jelapenos", Duration = 1, Cost = 0.98M
                },
                new Step {
                    Definition = "Add salami", Duration = 2, Cost = 2.33M
                },
                new Step {
                    Definition = "Heat oven", Duration = 15, Cost = 0.22M
                }
            };

            List <Step> cupcakeSteps = new List <Step>
            {
                new Step {
                    Definition = "Add flour", Duration = 2, Cost = 0.1M
                },
                new Step {
                    Definition = "Add eggs", Duration = 2, Cost = 0.25M
                },
                new Step {
                    Definition = "Add butter", Duration = 2, Cost = 0.24M
                },
                new Step {
                    Definition = "Add milk", Duration = 1, Cost = 0.46M
                },
                new Step {
                    Definition = "Mix ingredients", Duration = 2, Cost = 0.1M
                },
                new Step {
                    Definition = "Heat oven", Duration = 15, Cost = 0.22M
                }
            };

            Recipe pancakeFastFood = new PancakeFastFood(pancakeSteps);

            pancakeFastFood.GetRecipe();

            System.Console.WriteLine("\n\n");

            Recipe pancakeRestaurant = new PancakeRestaurant(pancakeSteps);

            pancakeRestaurant.GetRecipe();

            System.Console.WriteLine("\n\n");

            Recipe pizzaFastFood = new PizzaFastFood(pizzaSteps);

            pizzaFastFood.GetRecipe();

            System.Console.WriteLine("\n\n");

            Recipe pizzaRestaurant = new PizzaRestaurant(pizzaSteps);

            pizzaRestaurant.GetRecipe();

            System.Console.WriteLine("\n\n");

            Recipe cupcakeFastFood = new CupcakeFastFood(cupcakeSteps);

            cupcakeFastFood.GetRecipe();

            System.Console.WriteLine("\n\n");

            Recipe cupcakeRestaurant = new CupcakeRestaurant(cupcakeSteps);

            cupcakeRestaurant.GetRecipe();
        }