Exemplo n.º 1
1
        public static void Main()
        {
            teaFlavorFactory = new TeaFlavorFactory();

               takeOrders("chai", 2);
               takeOrders("chai", 2);
               takeOrders("camomile", 1);
               takeOrders("camomile", 1);
               takeOrders("earl grey", 1);
               takeOrders("camomile", 897);
               takeOrders("chai", 97);
               takeOrders("chai", 97);
               takeOrders("camomile", 3);
               takeOrders("earl grey", 3);
               takeOrders("chai", 3);
               takeOrders("earl grey", 96);
               takeOrders("camomile", 552);
               takeOrders("chai", 121);
               takeOrders("earl grey", 121);

               for (int i = 0; i < ordersMade; i++) {
               flavors[i].serveTea(tables[i]);
               }

            Tapper tap = new Tapper();
            tap.test("Flyweight test",
            ("total teaFlavor objects made: " + teaFlavorFactory.getTotalTeaFlavorsMade()) , ("total teaFlavor objects made: 3")
            );
            tap.done();
        }
Exemplo n.º 2
0
        public static void Main()
        {
            teaFlavorFactory = new TeaFlavorFactory();

            takeOrders("chai", 2);
            takeOrders("chai", 2);
            takeOrders("camomile", 1);
            takeOrders("camomile", 1);
            takeOrders("earl grey", 1);
            takeOrders("camomile", 897);
            takeOrders("chai", 97);
            takeOrders("chai", 97);
            takeOrders("camomile", 3);
            takeOrders("earl grey", 3);
            takeOrders("chai", 3);
            takeOrders("earl grey", 96);
            takeOrders("camomile", 552);
            takeOrders("chai", 121);
            takeOrders("earl grey", 121);

            for (int i = 0; i < ordersMade; i++)
            {
                flavors[i].serveTea(tables[i]);
            }

            Tapper tap = new Tapper();

            tap.test("Flyweight test",
                     ("total teaFlavor objects made: " + teaFlavorFactory.getTotalTeaFlavorsMade()), ("total teaFlavor objects made: 3")
                     );
            tap.done();
        }