Beispiel #1
0
        //The methods for for each bakery where they make the cookies
        public void Barrack()
        {
            Bakery bakery = Factory.CreateBakery("Barrack O bakery", store);

            bakery.stopwatch.Start();
            for (int i = 0; i <= 20;)
            {
                if (bakery.stopwatch.ElapsedMilliseconds == 1000)
                {
                    bakery.BakeCockie();
                    i++;
                }
            }
        }
Beispiel #2
0
        public void Trump()
        {
            Bakery bakery = Factory.CreateBakery("Trump Tower Café", store);

            bakery.stopwatch.Start();
            for (int i = 0; i <= 12;)
            {
                if (bakery.stopwatch.ElapsedMilliseconds == 2500)
                {
                    bakery.BakeCockie();
                    i++;
                }
            }
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            // Set up vendor list for costumer parameters
            List <Vendor> myVendorList = new List <Vendor>();
            Vendor        bakery1      = new Bakery("Baked hipsters");
            Vendor        bakery2      = new Bakery("Grannys");
            Vendor        juiceVendor1 = new JuiceVendor("Lord of the juices");

            myVendorList.Add(bakery1);
            myVendorList.Add(bakery2);
            myVendorList.Add(juiceVendor1);

            // Set up customers
            Customer c1 = new Customer("Nikita", myVendorList);
            Customer c2 = new Customer("Joakim", myVendorList);
            Customer c3 = new Customer("Robert", myVendorList);

            // prepare threads
            Thread vendorThread1   = new Thread(() => bakery1.CreateProduct(9));
            Thread vendorThread2   = new Thread(() => bakery2.CreateProduct(5));
            Thread vendorThread3   = new Thread(() => juiceVendor1.CreateProduct(8));
            Thread customerThread1 = new Thread(() => c1.StartGrabbingProduct(myVendorList));
            Thread customerThread2 = new Thread(() => c2.StartGrabbingProduct(myVendorList));
            Thread customerThread3 = new Thread(() => c3.StartGrabbingProduct(myVendorList));

            // Start Threads
            customerThread1.Start();
            customerThread2.Start();
            customerThread3.Start();
            vendorThread1.Start();
            vendorThread2.Start();
            vendorThread3.Start();

            // Keep window from closing
            Console.ReadKey(true);
        }