示例#1
0
        public GroupClient(HostMaster hostMaster, Waiter waiter1, Waiter waiter2)
        {
            Console.WriteLine("\nDes clients sont arrivés");

            int rdmNb = random.Next(2, 5);

            AttachMaitreHotel(hostMaster);
            AttachServeur(waiter1);
            AttachServeur(waiter2);

            Thread[] threadsGroupeClients = new Thread[rdmNb];

            for (int i = 0; i < rdmNb; i++)
            {
                int rdmType = random.Next(1, 3);
                //Console.WriteLine("{0}", rdmType);

                if (rdmType == 1)
                {
                    GroupClients.Add(ClientFactory.getClient("Client1"));
                }
                if (rdmType == 2)
                {
                    GroupClients.Add(ClientFactory.getClient("Client2"));
                }
            }

            lock (Lock)
            {
                int nextIndex = GetAvailableIndex();
                if (nextIndex == -1)
                {
                    nextIndex = UsedCounter.Count;
                    UsedCounter.Add(true);
                }

                ID = nextIndex;
            }

            NbrClient = GroupClients.Count();


            Console.WriteLine("ce groupe contient {0} personnes", NbrClient);

            //Console.WriteLine("Le client est bien un : {0}", GroupClients[0]);
            //Console.WriteLine("Le client est bien un : {0}", GroupClients[1]);
            Thread.Sleep(1000);
            Console.WriteLine("on a notifié le maitre de l'arrivée des clients");
            NotifyMaitreHotel("demanderTable");
        }
示例#2
0
 public ClientFactoryPattern()
 {
     ClientFactory ClientFactory = new ClientFactory();
     IClient       client        = ClientFactory.getClient("Client1");
     IClient       client2       = ClientFactory.getClient("Client2");
 }