public override void init() { foreach (AbstractBusinessProcess stream in businessProcessList) { AbstractBusinessEvent evt = stream.nextBusinessEvent(); eventMap.Add(currentTime + evt.getTime(), evt); } capital = startCapital; capitalHistory.Add(capital); }
public override void doStep() { Double key = eventMap.Keys.First(); AbstractBusinessEvent evt = eventMap[key]; eventMap.Remove(key); if (evt.GetType() == typeof(FinanceEvent)) { financeEvent((FinanceEvent)evt); } /// else if (evt.GetType() == typeof(SomeEvent)) /// someEvent((SomeEvent)evt) итд }
/// <summary> /// Обработка финансового события /// </summary> /// <param name="evt"></param> private void financeEvent(FinanceEvent evt) { capital += evt.getAmount(); currentTime += evt.getTime(); Console.WriteLine(capital); Console.Write(" " + evt.getAmount()); if (capital < 0) { stopRun(); } else { AbstractBusinessEvent newEvent = evt.getBusinessProcess().nextBusinessEvent(); eventMap.Add(newEvent.getTime() + currentTime, newEvent); capitalHistory.Add(capital); } }