示例#1
0
 public void baberThreadAction()
 {
     while (true)
     {
         while (!isSleeping)
         {
             if (barberShop.WaitingRoom.Count() > 0)
             {
                 Costumer c = barberShop.WaitingRoom[0];
                 barberShop.WaitingRoom.RemoveAt(0);
                 Console.WriteLine($"Barber {this.name} is cutting {c.Name}'s hair!");
                 Thread.Sleep(5000);
                 Console.WriteLine($"{c.Name} had the hair cut!");
             }
             else
             {
                 Sleep();
             }
         }
     }
 }
示例#2
0
        public void Arrive(Costumer c)
        {
            Console.WriteLine($"Costumer {c.Name} has arrived!");

            if (WaitingRoom.Count() < waitingRoomSize)
            {
                WaitingRoom.Add(c);
                if (barber.IsSleeping)
                {
                    Console.WriteLine($"Waking up the barber...");
                    barber.WakeUp();
                }
                else
                {
                    Console.WriteLine($"Barber is buzzy. {c.Name} it's waiting on {WaitingRoom.Count} chair.");
                }
            }
            else
            {
                Console.WriteLine($"The BarberShop is full! {c.Name} left! :(");
            }
        }