Esempio n. 1
0
        public static List <PizzaIngredient> Lings(params string[] args)
        {
            List <PizzaIngredient> tmp = new List <PizzaIngredient>();

            foreach (string i in args)
            {
                PizzaIngredient convertedstring = new PizzaIngredient(i);
                tmp.Add(convertedstring);
            }
            return(tmp);
        }
Esempio n. 2
0
        //Konstruktor
        public Pizza(string name = "EgenPizza", int price = 75, string pbotten = "Italiensk Pizzabotten", List <PizzaIngredient> pingredients = null)
            : base(name, price)
        {
            if (botten == "Italiensk Pizzabotten")
            {
                this.price += 50;
            }
            else if (botten == "Amerikansk Pizzabotten")
            {
                this.price += 70;
            }

            PizzaIngredient ost      = new PizzaIngredient("ost");
            PizzaIngredient tomatsos = new PizzaIngredient("Tomatsås");

            if (pingredients != null)
            {
                //garanterar att instansen har ost och tomatsås
                if (!pingredients.Contains(ost))
                {
                    pingredients.Add(ost);
                }
                if (!pingredients.Contains(tomatsos))
                {
                    pingredients.Add(tomatsos);
                }

                //Bygger upp instansens ingredienslista
                foreach (PizzaIngredient ing in pingredients)
                {
                    this.ingredients.Add(ing);
                }
            }
            else if (pingredients == null)
            {
                this.ingredients.Add(ost);
                this.ingredients.Add(tomatsos);
            }

            this.botten = pbotten;
        }
Esempio n. 3
0
 public void RemoveStuff(PizzaIngredient ping)
 {
     objIngredients.Remove(ping);
     this.price -= ping.price;
 }
Esempio n. 4
0
 public void AddStuff(PizzaIngredient ping)
 {
     objIngredients.Add(ping);
     this.price += ping.price;
 }