//Remove methods in the workstaion classes: checkes if there is available ingredients and then removes them. public static Sausage RemoveSausage() { CheckSausage(); Console.WriteLine("Take sausage from grill"); Sausage sausage = SausageBuffer.Dequeue(); return(sausage); }
//Check methods in the workstaion classes, makes sure that there are ingredients ready public static void CheckSausage() { if (SausageBuffer.Count == 0) { for (int i = 0; i < grillLimit; i++) { lock (SausageBuffer) { SausageBuffer.Enqueue((Sausage)IngredientFactory.CreateSausage()); } } Console.WriteLine("Putting sausage on grill {0}", SausageBuffer.Count + " " + "Sausages was placed on grill "); Thread.Sleep(3000); } }