/// <summary>
        /// This example uses the Bridge Pattern to separate high-level abstractions from implementation details.
        /// We have a Farmers Market, where different types of vendors process payments using different
        /// types of Payment Processing services, including credit cards and gift cards.
        /// The "Bridge" is the has-a relationship between vendors and their payment processors.
        /// Any FarmersMarketVendor has an object that implements the IProcessesPayments interface.
        /// Because every concrete FarmersMarketVendor is programmed to work with the high-level IProcessesPayments interface,
        /// the vendor logic can be extended independently of the implementations of the Payment Processors.  Likewise,
        /// the implementors of IProcessesPayments know nothing about the context in which they are used, and can be treated like a plugin.
        /// in fact, they can be used in many other contexts, so they've been extracted to the RealisticDependencies class library.
        /// By using object composition in this way, we avoid creating an exponential explosion in a potential
        /// subclass hierarchy for specific vendor-processor combinations.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private static void Main(string[] args)
        {
            Console.WriteLine("🧑‍🌾  Welcome to the Farmer's Market!");
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            const string organicGardens = "Organic Gardens";
            const string olsenFarm      = "Olsen Farm";
            const string andersenFarm   = "Andersen Farm";
            const string pleasantValley = "Pleasant Valley";
            const string hillsideRanch  = "Hillside Ranch";

            var creditCardProcessor = new CreditCardProcessor();
            var giftCardProcessor   = new GiftCardProcessor();

            var booth1 = new VegetableFarmer(creditCardProcessor);
            var booth2 = new VegetableFarmer(giftCardProcessor);
            var booth3 = new CattleFarmer(creditCardProcessor);
            var booth4 = new Florist(creditCardProcessor);
            var booth5 = new Florist(giftCardProcessor);

            booth1.ProcessCustomerPayment(10.00m, organicGardens);
            booth1.ProcessCustomerPayment(12.00m, organicGardens);
            booth1.ProcessCustomerPayment(1.50m, organicGardens);

            booth2.ProcessCustomerPayment(15.50m, olsenFarm);

            booth3.ProcessCustomerPayment(5.00m, andersenFarm);
            booth3.ProcessCustomerPayment(5.00m, andersenFarm);
            booth3.ProcessCustomerPayment(5.00m, andersenFarm);

            booth4.ProcessCustomerPayment(12.00m, pleasantValley);
            booth4.ProcessCustomerPayment(11.00m, pleasantValley);

            booth5.ProcessCustomerPayment(12.00m, hillsideRanch);
        }
 //Marc
 public WindowStock(Florist F)
 {
     InitializeComponent();
     Flori.Text = F.Nombre;
     listaflores.ItemsSource = F.ListaFlower;
     listatrees.ItemsSource  = F.ListaTree;    //conectamos las listas  .cs con las ListBox del .xaml
     listadeco.ItemsSource   = F.ListaDeco;
 }
Exemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Florist florist = db.Florists.Find(id);

            db.Florists.Remove(florist);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //Crea objeto floristeria
        private void clickFloristeria(object sender, RoutedEventArgs e)
        {
            Florist floristeria = new Florist(nombreFloristeria);

            //listaFlorist.Add(floristeria.Nombre);
            florist1 = floristeria;
            MessageBox.Show(floristeria.Nombre);
            nombreFloristeria.Text = "";
        }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "Id,FloristName,FloristAddress")] Florist florist)
 {
     if (ModelState.IsValid)
     {
         db.Entry(florist).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(florist));
 }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "Id,FloristName,FloristAddress")] Florist florist)
        {
            if (ModelState.IsValid)
            {
                db.Florists.Add(florist);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(florist));
        }
Exemplo n.º 7
0
        // GET: Florist/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Florist florist = db.Florists.Find(id);

            if (florist == null)
            {
                return(HttpNotFound());
            }
            return(View(florist));
        }
        static void Main(string[] args)
        {
            // Kwiaciarnia samoobsługowa
            Florist kwiaciarnia = new Florist();

            // Przychodzi klient janek. Ma 200 zł
            Console.WriteLine("JANEK I 200ZŁ");
            Customer janek = new Customer("Janek", 200);

            // Bierze różne kwiaty: 5 róż, 5 piwonii, 3 frezje, 3 bzy
            janek.get(new Rose(5));
            janek.get(new Peony(5));
            janek.get(new Freesia(3));
            janek.get(new Lilac(3));

            // Pewnie je umieścił na wózku sklepowyem
            // Zobaczmy co tam ma
            ShoppingCart wozekJanka = janek.getCart();
            Console.WriteLine("Przed płaceniem\n" + wozekJanka);

            // Teraz za to zapłaci...
            janek.pay();

            // Czy przypadkiem przy płaceniu nie okazało się,
            // że w wozku są kwiaty na które nie ustalono jescze cceny?
            // W takim razie zostałyby usunięte z wózka i Janek nie płaciłby za nie

            Console.WriteLine("Po zapłaceniu\n" + janek.getShoppingCart());

            // Ile Jankowi zostało pieniędzy?
            Console.WriteLine("Jankowi zostało : " + janek.getCash() + " zł");

            // Teraz jakos zapakuje kwiaty (może do pudełka)
            Box pudelkoJanka = new Box(janek);
            janek.pack(pudelkoJanka);

            // Co jest teraz w wózku Janka...
            // (nie powinno już nic być)
            Console.WriteLine("Po zapakowaniu do pudełka\n" + janek.getShoppingCart());

            // a co w pudełku:
            Console.WriteLine(pudelkoJanka);

            // Zobaczmy jaka jest wartość czerwonych kwiatów w pudełku Janka
            Console.WriteLine("Czerwone kwiaty w pudełku Janka kosztowały: " +
                        pudelkoJanka.valueOf("czerwony"));

            // Teraz przychodzi Stefan
            // ma tylko 60 zł
            Console.WriteLine("Stefan i 60zł");
            Customer stefan = new Customer("Stefan", 60);

            // ąle nabrał kwiatów nieco za dużo jak na tę sumę
            stefan.get(new Lilac(3));
            stefan.get(new Rose(5));

            // co ma w wózku
            Console.WriteLine(stefan.getShoppingCart());

            // płaci i pakuje do pudełka
            stefan.pay();
            Box pudelkoStefana = new Box(stefan);
            stefan.pack(pudelkoStefana);

            // co ostatecznie udało mu się kupić
            Console.WriteLine(pudelkoStefana);
            // ... i ile zostało mu pieniędzy
            Console.WriteLine("Stefanowi zostało : " + stefan.getCash() + " zł");
            Console.ReadKey();
        }