//Получение времени появления заявки private bool GetTime() { int rand_value = SMO.RandomNumber(-TimeSR, TimeSR); if (lastTime >= TimeForm + rand_value) { lastTime -= (rand_value + TimeForm); return(true); } return(false); }
static void Main(string[] args) { Double p1, p2, p3; try { Console.Write("p = "); p1 = Convert.ToDouble(Console.ReadLine().Replace('.', ',')); } catch (Exception e) { Console.Clear(); Console.WriteLine("p = {0}", 0.7); p1 = 0.7; } try { Console.Write("p2 = "); p2 = Convert.ToDouble(Console.ReadLine().Replace('.', ',')); } catch (Exception e) { Console.Clear(); Console.WriteLine("p = {0}", p1); Console.WriteLine("p1 = {0}", 0.7); p2 = 0.7; } try { Console.Write("p3 = "); p3 = Convert.ToDouble(Console.ReadLine().Replace('.', ',')); } catch (Exception e) { Console.Clear(); Console.WriteLine("p = {0}", p1); Console.WriteLine("p1 = {0}", p2); Console.WriteLine("p2 = {0}", 0.75); p3 = 0.75; } Console.WriteLine(); SMO smo = new SMO(p1, p2, p3); for (UInt32 i = 0; i < interval; i++) { smo.Next(); } smo.Printf(interval); Console.Read(); }
//Обновление - используется для выяснения покинет ли заявка очередь public bool Update(int _time) { timeNotWorkCount += _time; if (timeNotWorkCount > TimeNotWork) { int y = Number; if (SMO.RandomNumber(0, 100) <= percentExit) { EventExit(this); return(true); } } return(false); }
//Появление заявки public void Update(int _time) { lastTime += _time; foreach (var elem in bids) { if (elem.Update(_time)) { return; } } if (GetTime() && NewBid) { Bid B = new Bid(SMO.GetNumber(), Type, TimeManage, PercentType, PercentExit, TimeNotWork); B.EventExit += Elem_EventExit; bids.Add(B); lastTime -= TimeForm; OnUpdate("Заявка номер " + B.Number + " с типом " + (Type + 1).ToString() + " была добавлена в очередь", false); } OnGetInfo(Type, GetColor(), ToString()); }
//Определяем сменит ли тип заявка public bool IsChangeType() { return((SMO.RandomNumber(0, 100) > PercentType) ? false : true); }