예제 #1
0
        private static void CreateCookieBakery()
        {
            var random        = new Random();
            var cookiesToBake = random.Next(12, 20);

            SetGui(cookiesToBake);

            _bakery         = new Bakery(cookiesToBake);
            _totalCustomers = 3;

            CreateCustomers();
            CreateThreads();
        }
예제 #2
0
        public static void Main()
        {
            _bakery = new Bakery("Mamma's");

            _customers = new List <Customer> {
                new Customer("Ted"), new Customer("Fred"), new Customer("Greg")
            };

            _factoryThread  = new Thread(_bakery.ProduceCookies);
            _customerThread = new Thread(CustomerBuys);

            _factoryThread.Start();
            _customerThread.Start();

            _factoryThread.Join();
            _customerThread.Join();
        }
예제 #3
0
        static void Main(string[] args)
        {
            // Builds a bakery from the ground up using plywood and..
            // or just initialize it!
            var bakery = new Bakery(15);

            // Employees are all set, let's open.
            bakery.OpenBakery();

            // The bakery needs customers, say hello
            // to Ted, Fred and Greg
            var ted = new Person("Ted", bakery);
            var fred = new Person("Fred", bakery);
            var greg = new Person("Greg", bakery);

            // They're eager for cookies so go ahead chaps!
            ted.StartGrabbing();
            fred.StartGrabbing();
            greg.StartGrabbing();

            // If we don't put a Read or ReadLine here
            // we'll never know the end of this story.
            Console.Read();
        }
예제 #4
0
 static CookieFactory()
 {
     Bakery = new Bakery();
 }
예제 #5
0
 public Customer(string name, Bakery bakery)
 {
     Name    = name;
     _bakery = bakery;
     Cookies = new List <ICookie>();
 }