Beispiel #1
0
 public Coupon(BakeAction tDeal, string name, string itemDesc, string appliesTo)
 {
     Tag      = name;
     ItemDesc = itemDesc;
     Done     = false;
     Deal     = tDeal;
     Target   = appliesTo;
 }
Beispiel #2
0
        static void Main()
        {
            bool          bake    = true;
            Establishment Pierres = new Establishment();

            Pierres.AddItem("Muffin", "Just a muffin.", 2.50F, "muffins");
            Pierres.AddItem("Loaf", "A loaf of bread. Comes in different varieties.", 2F, "loaves");

            BakeAction threeForFive = () =>
            {
                Item  loaf     = Pierres.SearchItem("Loaf", Pierres.Tab.Cart);
                float indPrice = loaf.PricePer;
                loaf.Total = loaf.CountItemTotal();
                float o = 0;
                o          = loaf.Amount / 3;
                loaf.Total = (loaf.Total - (1.0F * o));
                Console.WriteLine("---------------------------");
                Console.Write("Buy 3 loaves for 5$");
                if (o > 0)
                {
                    Console.Write(" applied " + o + " times!");
                    Console.WriteLine("");
                }
                else
                {
                    Console.Write(" applied!");
                    Console.WriteLine("");
                }
                Console.WriteLine("---------------------------");
                Pierres.SearchItem("Loaf", Pierres.Tab.Cart).Total = loaf.Total;
            };

            BakeAction twoForOne = () =>
            {
                Item  muffin   = Pierres.SearchItem("Muffin", Pierres.Tab.Cart);
                float indPrice = muffin.PricePer;
                muffin.Total = muffin.CountItemTotal();
                Console.WriteLine(muffin.Total);
                float o = 0;

                o            = muffin.Amount / 3;
                muffin.Total = (muffin.Total - (2.50F * o));
                Console.WriteLine("---------------------------");
                Console.Write("Buy 2 get one free on muffins");
                if (o > 0)
                {
                    Console.Write(" applied " + o + " times!");
                    Console.WriteLine("");
                }
                else
                {
                    Console.Write(" applied!");
                    Console.WriteLine("");
                }
                Console.Write(muffin.Total);
                Console.WriteLine("---------------------------");
                Pierres.SearchItem("Muffin", Pierres.Tab.Cart).Total = muffin.Total;
            };

            Pierres.Coupons.Add(new Coupon(twoForOne, "Buy 2 get one free", "Savings of 2.50$ per coupon!", "muffin"));
            Pierres.Coupons.Add(new Coupon(threeForFive, "Get 3 loaves ", "Savings of 1$ per coupon!", "loaf"));

            Console.WriteLine("Welcome to Pierre's!");
            Help();
            while (bake == true)
            {
                Buffer(Pierres);
            }
        }