Пример #1
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;
     }
 }
Пример #2
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;
 }
Пример #3
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();
        }
Пример #4
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();
 }
Пример #5
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);
                }
            }