Ejemplo n.º 1
0
        //==========================================================
        /*         public enum servers
                  {
                            Not_assigned = 0,
                            Able = 1 ,
                            baker = 2 ,

                       }    */
        public static int check_which_server(Customer x, server a, server b)
        {
            if (a.is_idle == false)    // Able is  busy
            {

                if (b.is_idle == true)  // Baker is free
                {
                    x.which_server = "Baker";
                    b.is_idle = false;
                    b.Finish_service = b.Generate_Baker_Service_Time();
                    x.Service_time = b.Finish_service;
                }
                else if (a.is_idle == false && b.is_idle == false)   // baker is also busy
                {
                    // to obtain the delay of the customer
                    // find min of both server's finish time   - arrival time of customer
                    int t = Math.Min(a.Finish_service, b.Finish_service);
                    x.delay = t - x.Get_Arrival_time();

                    if (t == a.Finish_service)
                    {
                        a.is_idle = false;
                        a.Finish_service = a.Generate_Able_Service_Time();
                        x.Service_time = a.Finish_service;
                    }
                    else
                    {
                        b.is_idle = false;
                        b.Finish_service = b.Generate_Baker_Service_Time();
                        x.Service_time = b.Finish_service;
                    }
                }

                else
                {
                    x.which_server = "Able";
                    a.is_idle = false;
                    a.Finish_service = a.Generate_Able_Service_Time();
                    x.Service_time = a.Finish_service;

                }
            }
            return x.Service_time;
        }